Hi,
I have *this form:*
class registerForm(forms.Form):
aNumber = forms.IntegerField(
label='Some Integer Field',
max_value=99999999,
min_value=1000000,
help_text='7 digits min and 8 digits max',
error_messages={
'invalid':'Only numbers pls!',
'min_value':'min 7 digits!',
'max_value':'max 8
digits!',
}
)
*the view:*
def register_form(request):
if request.method == 'POST':
form = registerForm(request.POST)
if form.is_valid():
register = registerModel.objects.get_or_create(
aNumber=form.cleaned_data['aNumber']
)
return HttpResponseRedirect('/home/')
else:
form = registerForm()
vars = RequestContext(request, { 'form':form })
return render_to_response('register_form.html', vars)
*the model:
*class registerModel(models.Model):
aNumber = models.IntegerField(primary_key=True,unique=True,db_index=True)*
*
Well, if I put any character like "123asd" in the form field, the form
is re-rendered with the label mesaage "Only numbers pls!" at the top
of the same field rigth? that's good
But if I put only integer digits violating the rule min_value or max_value,
i get a TypeError page with:
"TypeError at /myProject/myApp/form/
not all arguments converted during string formatting
....
Exception Type: TypeError
Exception Value: not all arguments converted during string formatting
Exception Location: /usr/lib/pymodules/python2.5/django/forms/fields.py in
clean, line 190
Python Executable: /usr/bin/python
...
/usr/lib/pymodules/python2.5/django/forms/fields.py in clean
...
190. raise ValidationError(self.error_messages['min_value'] %
self.min_value)
..."
Why the error_message 'min_value' doesn't work as the error_message
'invalid'?
What is wrong?
Thanks a lot for any help.
--
---
Key fingerprint = 0CCB D0F6 47F2 5F70 6F40 53D3 7537 A0E4 94FC 40EE
----------------------------------
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---