-
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
Currency not being updated #664
Comments
A year old but... This expected behavior. You're using DJMoney uses If you want to use |
@nitsujri I think you are right. Maybe django-money should be doing a Or maybe it should try to automatically map field names provided to I'd try to argue to not use magic here, just because people might have more complex queries for their update statements and maybe it's best to just emit the warning. |
I'm probably talking beyond my paygrade here as I'm relatively new to Django, but I'm not sure if that is realistically possible or even if it should be done. Looking at how But more philosophically, I don't believe DJMoney needs to take this on. While it's "surprising and weird" to new comers to Django, it's very much a Django design choice. You go Admittedly, I'm very familiar with from Rails ( [Edit] |
This is a good point. I can only say that from experience, "when there is a will, there is a way". But most likely, the most stable way will be to just try to warn the developer.
Definitely good to only display relevant warnings or offer a way to silence them when doing deliberate actions 👍 |
This is a good action of no one comes up with a PR :) I wouldn't rule out that if it is reasonably problematic for someone and they want to propose a way forward and add test cases, then it's fine.. otherwise, yeah seems likely that this will be closed as a #wontfix. |
@benjaoming in Rails we use the linter, Rubocop, it has a specific rule against this: https://docs.rubocop.org/rubocop-rails/cops_rails.html#railsskipsmodelvalidations Following this, the recommendation becomes getting it with Flake8 or Black. Flake8 has this library: https://github.com/rocioar/flake8-django Contributing an |
I've been experiencing some strange behaviour when trying to update MoneyField in bulk updates. I have a product model which may store products with money fields in different currencies so i have been using nullable money fields. The problem arises when trying to update the MoneyField after the product has already been created.
I've tried to outline the steps below to reproduce, hope it helps.
Stack
Django==4.0
django-money==2.1.1
postgres 14
Model
Create & Update
Normal operation on single items seems to work fine
Bulk Update
This results in the amount being updated but not the currency, the same occurs when using Product.objects.bulk_update()
Bulk Create with Money Field
Updating individual entries
The text was updated successfully, but these errors were encountered: