Hi,

I was looking for a way to customize the error message when trying to
submit an existing value for a unique field (using a ModelForm).
According to this request (http://code.djangoproject.com/ticket/8913),
I am not the first one to look for such a feature, and I'm happy to
wait for it.

My current solution is quite inelegant, though:

if register_form.errors.has_key('email') and (register_form._errors
['email'] == ['Customer with this E-Mail already exists.']):
        register_form._errors['email'] = ErrorList(['My custom error message
goes here.'])

But I also found this snippet (http://www.djangosnippets.org/snippets/
1228/), and the first comment confused me. I never had to pass an
instance when instantiating the form - the is_valid() method created
the desired error message and linked it to the appropriate field.

Am I missing something?

Kind regards,
Jan
--~--~---------~--~----~------------~-------~--~----~
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