Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#14380 closed (invalid)

Form provided by modelform_factory fails when using fields attribute

Reported by: Olivier Le Thanh Duong Owned by: nobody
Component: Forms Version: 1.2
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When creating a form using modelform_factory, setting the fields attribute and trying to display it, it fail with the following error :
AttributeError: 'NoneType' object has no attribute 'label'

Steps to reproduce :

  1. run manage.py shell
  2. import any model ex : from django.contrib.flatpages.models import FlatPage
  3. from django.forms.models import modelform_factory
  4. modelform_factory(FlatPage, fields='title')().as_p()

(or as_ul or as_table)

  • > AttributeError: 'NoneType' object has no attribute 'label'

When not using this attribute or when using the excludes attribute this works as expected
Using django 1.2.3 here

Change History (3)

comment:1 by Olivier Le Thanh Duong, 14 years ago

A friend can reproduce this bug using 1.1.1

comment:2 by Matt McClanahan, 14 years ago

Resolution: invalid
Status: newclosed

Per the docs, the fields argument expects a list, not a string.

comment:3 by Olivier Le Thanh Duong, 14 years ago

Hum this was a error of retranscription when I wrote the bug, I had actually test it with a tuple like in the doc and it didn't work either.
However when testing with a proper list it is actually working. It seems a bit strange.

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