0

Is there any way to launch custom errors in the admin site like that?:

enter image description here

Currently I throw the error with

raise forms.ValidationError('error')

but shows the debug error screen

Blainn
  • 113
  • 1
  • 6
  • http://stackoverflow.com/questions/2967110/django-validation-error-in-admin should give you an idea – karthikr Jun 03 '13 at 16:47

1 Answers1

0

Where are you putting the raise forms.ValidationError('error')?

In your form clean() method is a good place to raise custom errors. You can even do def clean_fieldname() to preform specific validation for one field. From the django docs

from django import forms

    class ContactForm(forms.Form):
        # Everything as before.
        ...

        def clean_recipients(self):
            data = self.cleaned_data['recipients']
            if "fred@example.com" not in data:
                raise forms.ValidationError("You have forgotten about Fred!")

            # Always return the cleaned data, whether you have changed it or
            # not.
            return data

This link also could help

Community
  • 1
  • 1
Austin
  • 4,296
  • 6
  • 40
  • 52