Looks like you want to use this field:
https://docs.djangoproject.com/en/dev/ref/models/fields/#positiveintegerfield

On Sat, Sep 24, 2011 at 11:54 PM, jenia ivlev <jenia.iv...@gmail.com> wrote:

> I have a model M that has a field num=models.IntegerField()
> I have a modelform called 'F' for model 'M'.
> I want to ensure that num is never negative.
>
> If I do validation in my form class, 'F', then i can do clean_num():
> if negative than throw ValidationError('Num can never be negative').
> This validationerror will be automatically redisplayed to the user by
> redirecting him to back to the form that he submitted and displaying
> the 'Num can never be negative' message on top of the num field.
> Thats all done automatically by django as soon as I throw the
> validationerror from the clean_fieldname method.
>
> I would like to be able to do all that, but in the model class.
>
> So F, that has a FormField for the ModelField 'num' , will fail and
> display the error message defined in the model class that its
> representing.
> Also F2 and Fxxx will do the same if they all represent 'M' and have a
> FormField for ModelField num.
>
> How can I achieve this?
>
> Thank you for your time and kind concern.
> jenia
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to