#4330 closed (fixed)
formtools.preview.FormPreview unused_name uses non-instance form
Reported by: | Owned by: | Adrian Holovaty | |
---|---|---|---|
Component: | contrib.formtools | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Hi there,
The FormPreview on the unused_name function uses self.form.fields from the form class, but form.fields isn't available on the Class but on the instance of a form so FormPreview raises an AttributeError when it's instances are called:
Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py" in get_response 77. response = callback(request, *callback_args, **callback_kwargs) File "/usr/lib/python2.4/site-packages/django/contrib/formtools/preview.py" in __call__ 68. stage = {'1': 'preview', '2': 'post'}.get(request.POST.get(self.unused_name('stage')), 'preview') File "/usr/lib/python2.4/site-packages/django/contrib/formtools/preview.py" in unused_name 86. f = self.form.fields[name] AttributeError at /ab/add/post/ type object 'CuentaNewForm' has no attribute 'fields'
Maybe it should read form.base_fields from the class or instantiate a form to read .fields
Attachments (1)
Change History (8)
by , 17 years ago
comment:1 by , 17 years ago
Has patch: | set |
---|
comment:2 by , 17 years ago
Triage Stage: | Unreviewed → Ready for checkin |
---|
This is broken since [4437] (January) some regression test should have spotted this but that was not the case ;(
Anyway, the attached patch solves a broken thing so I'm marking it Ready for Check-in, for the test problem I'd better file a new ticket so we can get this solved ASAP.
triagers: feel free to move back to Accepted and +needs_test if you feel we should get the test within the patch at once ;)
comment:3 by , 17 years ago
The test can wait, Mark, only because we need some infrastructure work so that tests for contrib/ apps can live under their app, rather than in the main test dir. That discussion is happening on django-dev right now.
follow-up: 5 comment:4 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:5 by , 17 years ago
Replying to mtredinnick:
(In [5293]) Fixed #4330 -- Fixed typo when retrieving field names. Patch from Marc Fargas.
Thanks, but the patch came from Daniel ;)
comment:6 by , 17 years ago
Oh, sorry about that, Daniel.
Guess you owe us one patch, then, Marc. :-)
Patch to use base_fields instead of fields.