Tuesday, August 27, 2013

Re: DecimalField

Thanks Tom.  I actually tried that at one point and this is the error I received:  not all arguments converted during string formatting.

The required and invalid error message keys work fine but it appears the max_decimal_places key is being ignored. Has anyone seen this before?  BTW, I am using Django 1.5.2

On Sunday, August 25, 2013 5:47:00 AM UTC-4, Derrick Jackson wrote:
Hi All,

My Model has a DecimalField:      

amount = models.DecimalField(max_digits=19, decimal_places=2, verbose_name='Amount')

My ModelForm has the following:  

self.fields['amount'] = forms.DecimalField(error_messages={
            'required': 'Amount is required.',
            'invalid': 'Numbers only.',
            'max_decimal_places': 'Only 2 decimal places.'})

However the max_decimal_places validation check does not seem to be working.  Is there a certain way I need to use this that will properly allow the error to be thrown?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment