On Mon, Feb 16, 2009 at 4:26 AM, coan <a.ne...@gmail.com> wrote: > > I'm validating a form, and use forms.IntegerField(min_value=0,). > > If I submit a -1 value in that field, it throws a TypeError: not all > arguments converted during string formatting. > How come it doesn't raise a forms.ValidationError, and how should I > catch a negative value in this field?
I cannot recreate any error like what you describe with the information you have provided: Python 2.5.1 (r251:54863, Jul 31 2008, 23:17:40) [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) >>> from django import forms >>> class IForm(forms.Form): ... nzint = forms.IntegerField(min_value=0,) ... >>> iform = IForm(data={'nzint': -1}) >>> iform.is_valid() False >>> iform.errors {'nzint': [u'Ensure this value is greater than or equal to 0.']} >>> Repeating myself for about the bazillionth time: snippets of the actual code in use use and the full traceback of the error seen are much more likely to get useful replies than brief word sketches of the code and the barest bones of the debug information from the error. Alternatively, an attempt to recreate the error with the minimal information you think is relevant might reveal how the stripped-down case works and possibly provide a clue as to what's different about the code exhibiting the error, allowing you to solve the problem on your own. Karen --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---