On Tuesday, March 15, 2011 2:36:45 PM UTC, Ben Dembroski wrote: > > > Hi Tom, > > Thanks for your reply. (You're right, my example was lousy). > > I did in fact try what you suggested earlier on, and got the the > following error: > > AttributeError at /people/add/ > > 'ValidationError' object has no attribute 'message_dict' > > <snip> > I have this in the code: > from django.core.exceptions import ValidationError, NON_FIELD_ERRORS > > and the code is currently so: > except ValidationError, e: > errormsg = e.message_dict[NON_FIELD_ERRORS] > > form = EditPerson() > return render_to_response('personentry.html', { 'form' : form, > 'errormsg': errormsg },context_instance=RequestContext(request)) >
Why are you trying to catch the ValidationError? The whole point is that this is caught by the form's `clean()` method and then the message appears in the error dictionary. -- DR. -- 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.