#26189: Models with decimal fields raise errors on calling full_clean
-------------------------------+--------------------------------------
     Reporter:  lenniezelk     |                    Owner:  nobody
         Type:  Bug            |                   Status:  new
    Component:  Uncategorized  |                  Version:  1.9
     Severity:  Normal         |               Resolution:
     Keywords:                 |             Triage Stage:  Unreviewed
    Has patch:  0              |      Needs documentation:  0
  Needs tests:  0              |  Patch needs improvement:  0
Easy pickings:  0              |                    UI/UX:  0
-------------------------------+--------------------------------------

Comment (by lenniezelk):

 I have added the relevant model in an attachment. The affected field is
 `amount`. Just creating a model instance and running `full_clean` on it
 raises a `ValidationError`. Error is raised even after Here is an iPython
 session I ran:

 {{{#!python
   In [1]: user = User.objects.get(email='[email protected]')

 In [2]: account = list(user.user_accounts.first())
 ---------------------------------------------------------------------------
 TypeError                                 Traceback (most recent call
 last)
 <ipython-input-2-3e7c6aabfd88> in <module>()
 ----> 1 account = list(user.user_accounts.first())

 TypeError: 'Account' object is not iterable

 In [3]: account = user.user_accounts.first()

 In [4]: currency = Currency.objects.first()

 In [5]: transaction = Transaction(account=account, user=user,
 currency=currency, amount=34.22, date=timezone.now(),
 exchange_rate=ExchangeRate.objects.first())

 In [6]: transaction.full_clean()
 ---------------------------------------------------------------------------
 ValidationError                           Traceback (most recent call
 last)
 <ipython-input-6-343b6af108cd> in <module>()
 ----> 1 transaction.full_clean()

 /home/vagrant/.virtualenvs/cashbox/lib/python3.4/site-
 packages/django/db/models/base.py in full_clean(self, exclude,
 validate_unique)
    1134
    1135         if errors:
 -> 1136             raise ValidationError(errors)
    1137
    1138     def clean_fields(self, exclude=None):

 ValidationError: {'amount': ['Ensure that there are no more than 12 digits
 in total.']}

 In [7]: transaction.save()

 In [8]: transaction.full_clean()
 ---------------------------------------------------------------------------
 ValidationError                           Traceback (most recent call
 last)
 <ipython-input-8-343b6af108cd> in <module>()
 ----> 1 transaction.full_clean()

 /home/vagrant/.virtualenvs/cashbox/lib/python3.4/site-
 packages/django/db/models/base.py in full_clean(self, exclude,
 validate_unique)
    1134
    1135         if errors:
 -> 1136             raise ValidationError(errors)
    1137
    1138     def clean_fields(self, exclude=None):

 ValidationError: {'amount_primary': ['Ensure that there are no more than
 12 digits in total.'], 'amount': ['Ensure that there are no more than 12
 digits in total.']}
   }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/26189#comment:3>
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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.03505508eba00d0170fb17ec23d35970%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to