Opened 17 years ago

Closed 17 years ago

Last modified 16 years ago

#4330 closed (fixed)

formtools.preview.FormPreview unused_name uses non-instance form

Reported by: Daniel Blasco <daniel@…> 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)

4330.diff (513 bytes ) - added by Daniel Blasco <daniel@…> 17 years ago.
Patch to use base_fields instead of fields.

Download all attachments as: .zip

Change History (8)

by Daniel Blasco <daniel@…>, 17 years ago

Attachment: 4330.diff added

Patch to use base_fields instead of fields.

comment:1 by anonymous, 17 years ago

Has patch: set

comment:2 by Marc Fargas <telenieko@…>, 17 years ago

Triage Stage: UnreviewedReady 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 Malcolm Tredinnick, 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.

comment:4 by Malcolm Tredinnick, 17 years ago

Resolution: fixed
Status: newclosed

(In [5293]) Fixed #4330 -- Fixed typo when retrieving field names. Patch from Marc Fargas.

in reply to:  4 comment:5 by Marc Fargas <telenieko@…>, 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 Malcolm Tredinnick, 17 years ago

Oh, sorry about that, Daniel.

Guess you owe us one patch, then, Marc. :-)

comment:7 by Marc Fargas <telenieko@…>, 17 years ago

Uhm.. I'll have to take a look at Reports then... ;)

Note: See TracTickets for help on using tickets.
Back to Top