#25973 closed Bug (duplicate)
Django 1.9 CBV - Form field error still being rendered in template after deletion
Reported by: | pshumba | Owned by: | nobody |
---|---|---|---|
Component: | Generic views | Version: | 1.9 |
Severity: | Normal | Keywords: | Form error deletion |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Before rendering template code is supposed to remove email field error on unique validation
"Foo with this Email address already exists."
Code works on previous version of Django 1.8.4
Django 1.9 displays error in template
Model:
class Foo(models.Model): email = models.EmailAddress(unique = True)
View:
from django.views.generic import CreateView Class BarCreateView(CreateView): def form_invalid(self, form): if form.has_error('email', 'unique'): form.errors.pop('email', None) return super(BarCreateView, self).form_invalid(form)
Template:
<form id="login_form" method="post" action=""> {% csrf_token %} {{form}} <input type="submit" value="Submit" /> </form>
Note:
See TracTickets
for help on using tickets.
I believe this is a duplicate of #25548, which will be fixed in the upcoming 1.9.1 release.
As a work around until 1.9.1 is released, you can replace the super call
with it's implementation (it's only one line long)