#18613: DecimalField returns an int in some circumstances -------------------------------------+------------------------------------- Reporter: yac | Owner: nobody Type: Uncategorized | Status: closed Component: Database layer | Version: 1.4 (models, ORM) | Resolution: invalid Severity: Normal | Triage Stage: Keywords: DecimalField | Unreviewed Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+------------------------------------- Changes (by anonymous):
* status: new => closed * needs_better_patch: => 0 * component: Forms => Database layer (models, ORM) * needs_tests: => 0 * needs_docs: => 0 * resolution: => invalid Comment: If you want the object returned from `get_or_create` to have a `decimal.Decimal` value for the `my_decimal` field, then pass a `decimal.Decimal` value in on the `get_or_create` call. The fact that Django will accept other types here, and still allow the model to be created successfully and correctly, may be somewhat surprising but can't at this point be changed without breaking backwards-compatibility. Even coercing the field values to match expected types would have backwards- compatible implications. Django takes what's provided, if that's close enough to what's needed for the field type things work, but Django doesn't enforce strict type checking on this (or any?) field, nor does it "fixup" the field values in the returned model object. The ticket description doesn't provide any guidance on what's wanted for a fix here, so I'm not sure what to do other than close this as invalid since this is longstanding behavior that cannot reasonably be changed now. -- Ticket URL: <https://code.djangoproject.com/ticket/18613#comment:1> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.