How to display Django '__all__' form errors in a template?

I have the following form code:

# forms.py class SomeForm(forms.Form): hello = forms.CharField(max_length=40) world = forms.CharField(max_length=40) def clean(self): raise forms.ValidationError('Something went wrong') # views.py def some_view(request): if request.method == 'POST': form = SomeForm(request.POST) if form.is_valid(): pass else: form = SomeForm() data = { 'form': form } return render_to_response( 'someform.html', data, context_instance=RequestContext(request) ) # someform.html {{ form.hello }} {{ form.hello.errors }} {{ form.world }} {{ form.world.errors }} 

How can I display errors from the __all__ key at the template level without having to extract it as a separate one? I want to avoid the following:

  if form.errors.has_key('__all__'): print form.errors['__all__'] 
+42
django django-forms
Mar 26 '10 at 18:52
source share
2 answers
 {{ form.non_field_errors }} 
+91
Mar 26
source share

{{ form.non_field_errors }} for errors related to non-field form

{{ form.password.errors }} for errors associated with a text field such as passoword in this case

+22
Aug 11 '11 at 7:30
source share



All Articles