Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#14380 closed (invalid)

Form provided by modelform_factory fails when using fields attribute

Reported by: olethanh 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: UI/UX:


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 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 Changed 5 years ago by olethanh

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

A friend can reproduce this bug using 1.1.1

comment:2 Changed 5 years ago by mattmcc

  • Resolution set to invalid
  • Status changed from new to closed

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

comment:3 Changed 5 years ago by olethanh

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