-
Notifications
You must be signed in to change notification settings - Fork 311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'MoneyField' object has no attribute '_currency_field' when running migration #731
Comments
Likely caused by #726 (i.e. caused by me) although I don't have the time to research this further at the moment |
Thanks for the update. Workaround for me is to use django-money v3.2 |
I'm sure downgrading to 3.2 works because it's indeed the new code that causes this. |
Given that I caused this my 2 cents before I finaly remove myself from this issue for lack of time 😄 The bug is that, in the recent PR, it was made so that in the "migration world" The current issue proves that assumption incorrect: when RunPython migrations are run, the "fake realities" are needed to create actual object-instances.
The simplest (but ugly, and potentially incomplete) solution would be to simply a guard like A more proper solution would be to link MoneyField and CurrencyField together using the
|
Any updates on this? I'm having the same issue when adding a data migration. |
Had a similar error creating a migration that didn't involve any MoneyFields but was interacting with a model which contains a MoneyField. Very strange but downgrading to v3.2 |
Thanks for leaving it broken instead of reverting your PR. It's awesome, because I was on 3.4 and now have to move to 3.2. |
Hi, I don't agree with grimwm's wording. I'd like to thank the authors for the work they put into maintenance of this library. On the other hand, we also had to downgrade to 3.2 and it seems reverting the PR might a good thing. @benjaoming What do you think? |
While I think that the problem is reasonably frustrating, I don't think blaming the original author is constructive in any way. Anybody with sufficient bandwidth and the desire to fix it could have opened a PR reverting that change (as per your suggestion). Or, better, adding some test cases, even failing ones (under xfail) would be a good step to prevent such issues in the future. Other than that I do think we need to have stricter rules for incoming PRs - changes like that should always have test cases that are failing on the main branch and don't on the PR's one. I don't have much capacity for diving deeper into the details at the moment but would be happy to collaborate on reviewing PRs to fix it later on. |
The thing is that, as a random contributor, it is difficult to guess it the maintainers prefer to revert the PR or fix it. So is sending a PR with revert of #726 and tests proving that the revert fixed the current issue a good way forward? |
Another thing I'd like to add to this area is a set of tests with Hypothesis, specifically stateful tests. Years ago I had some prototypes but didn't finish them. The idea is to define a state machine where transitions are adding / changing / removing |
@washeck I think that reverting is strictly better than having an internal error, as the previous state presumably has a workaround (manually writing undetected migrations) and a smaller impact. Then we can work on a proper fix for the original problem that PR aimed to solve. |
is there a work around for this that doesn't involve downgrading? Having the same issue still on 3.4 when querying a model with MoneyField in a custom migration |
Hi there,
I have a migration to add the following field:
I added some code to update this field in a view and that all appears to be working fine.
Now I want to add a data migration like below:
However this is producing the following error:
Not sure if I'm missing something?
Project uses:
The text was updated successfully, but these errors were encountered: