Django

Code

Ticket #4330 (closed: fixed)

Opened 2 years ago

Last modified 2 years ago

formtools.preview.FormPreview unused_name uses non-instance form

Reported by: Daniel Blasco <daniel@fargas.com> Assigned to: adrian
Milestone: Component: django.contrib.formtools
Version: SVN Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

4330.diff (0.5 kB) - added by Daniel Blasco <daniel@fargas.com> on 05/18/07 04:23:34.
Patch to use base_fields instead of fields.

Change History

05/18/07 04:23:34 changed by Daniel Blasco <daniel@fargas.com>

  • attachment 4330.diff added.

Patch to use base_fields instead of fields.

05/18/07 04:23:43 changed by anonymous

  • needs_better_patch changed.
  • has_patch set to 1.
  • needs_tests changed.
  • needs_docs changed.

05/18/07 04:38:51 changed by Marc Fargas <telenieko@telenieko.com>

  • stage changed from Unreviewed to 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 ;)

05/19/07 13:47:20 changed by mtredinnick

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 ) 05/19/07 13:54:35 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to fixed.

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

(in reply to: ↑ 4 ) 05/19/07 17:30:25 changed by Marc Fargas <telenieko@telenieko.com>

Replying to mtredinnick:

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

Thanks, but the patch came from Daniel ;)

05/19/07 17:32:30 changed by mtredinnick

Oh, sorry about that, Daniel.

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

05/19/07 17:35:47 changed by Marc Fargas <telenieko@telenieko.com>

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


Add/Change #4330 (formtools.preview.FormPreview unused_name uses non-instance form)




Change Properties
Action