Hi,
I don't understand why the following code produces an error (see
below):
>>> from django import forms
>>> from ishop.bo.models import Document
>>> d = Document.objects.get(pk=80000)
>>> print d.date_due
2009-08-28
>>> class df(forms.ModelForm):
>>> class Meta:
>>> model = Document
>>> fields = ('status', 'date_due', 'number')
>>> f = df(instance=d)
>>> f.as_table()
produces the following error
---------------------------------------------------------------------------
AttributeError Traceback (most recent call
last)
C:\Users\Marc\Python\dj\ishop\<ipython console> in <module>()
C:\Python25\lib\site-packages\django\forms\forms.pyc in as_table(self)
188 def as_table(self):
189 "Returns this form rendered as HTML <tr>s -- excluding
the <table></table>."
--> 190 return self._html_output(u'<tr><th>%(label)s</th><td>%
(errors)s%(field)s%help_text)s</td></tr>', u'<tr><td colspan="2">%s</
td></tr>', '</td></tr>', u'<br />%s', False)
191
192 def as_ul(self):
C:\Python25\lib\site-packages\django\forms\forms.pyc in _html_output
(self, normal_row, error_row, row_ender, help_text_html,
errors_on_separate_row)
140 output, hidden_fields = [], []
141 for name, field in self.fields.items():
--> 142 bf = BoundField(self, field, name)
143 bf_errors = self.error_class([conditional_escape
(error) for error in bf.errors]) # Escape and cache in local variable.
144 if bf.is_hidden:
C:\Python25\lib\site-packages\django\forms\forms.pyc in __init__(self,
form, field, name)
344 self.html_name = form.add_prefix(name)
345 self.html_initial_name = form.add_initial_prefix(name)
--> 346 if self.field.label is None:
347 self.label = pretty_name(name)
348 else:
AttributeError: 'NoneType' object has no attribute 'label'
The same code works fine when removing the 'date_due' field from the
list of fields to be displayed.
Thanks for any hint
Marc
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---