Getting the global error of a form

1
2
3
4
5
class MyForm(forms.Form):

    def get_global_errors(self):
        errors = dict(self.errors)
        return list(errors.get("__all__", []))

More like this

  1. Complex Formsets, Redux by smagala 3 years, 3 months ago
  2. Model Forms: Clean unique field by johnboxall 4 years, 6 months ago
  3. Load initial form fields from GET parameters by ramen 3 years, 7 months ago
  4. load m2m fields objects by dirol 3 years ago
  5. AjaxForm Base Classes by btaylordesign 2 years, 3 months ago

Comments

justinw (on May 19, 2007):

def get_global_errors(self): return self.errors and self.errors.get('_all_',[])

#

Archatas (on September 12, 2008):

I am not sure about the situation at the time of writing this post, but global errors can be accessed by {{ form.non_field_errors }}

#

(Forgotten your password?)