How do I display non-field errors at the bottom of a form?
19 views
Skip to first unread message
richard.prosser
unread,
Feb 20, 2012, 12:10:10 PM2/20/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
Essentially I want to ensure that a DB record provided via a form is
unique AND be able to handle the error(s) produced in my own way.
After lengthy and often fruitless searching I decided that a
Model.validate_unique() call to trap the ValidationError would be
suitable, so that I could populate my own 'error_message' form
variable with the Django-produced "[model] with this [fields] already
exists" message.
However this message is still displayed at the top of the form, via
'top_errors' in django.forms I believe.
I have looked for a way to (artifically) declare the 'unique_together'
fields to be OK once I have captured the ValidationError message - so
as to inhibit the above behaviour - but there doesn't seem to be one.
So can anyone suggest a better approach?
Apologies in advance for not being able to supply any code but it is
subject to IPR restrictions.