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. AjaxForm Base Classes by btaylordesign 1 year, 2 months ago
  2. Tamper safe HiddenFields by alexmeisel 3 years, 6 months ago
  3. Querying on existence of a relationship by ubernostrum 4 years, 9 months ago
  4. ReCaptcha for django forms (improved and with remoteip) by pinkeen 1 year, 5 months ago
  5. Model Locking Mixin & Decorator (MySQL Advisory Locks) by pio 1 year 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?)