#8436: Silent crash in forms rendering
---------------------------------+------------------------------------------
Reporter: stilldodge | Owner: nobody
Status: new | Milestone:
Component: Forms | Version: SVN
Resolution: | Keywords: errors, Form
Stage: Unreviewed | Has_patch: 0
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
---------------------------------+------------------------------------------
Changes (by mtredinnick):
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Old description:
> Given form as follows, as_table crashes
>
> I expect this has to do with collisions to properties of Form and
> variations of problems will probably happen with (errors, changed_data,
> media)
>
> class TestForm(forms.ModelForm):
> errors = forms.CharField(widget=forms.HiddenInput)
> class Meta:
> model = MyModel
>
> Stack trace
>
> c:\django\django\forms\forms.py in as_table(self)
> 175 def as_table(self):
> 176 "Returns this form rendered as HTML <tr>s -- excluding
> the <table></table>."
> --> 177 return
> self._html_output(u'<tr><th>%(label)s</th><td>%(errors)s%(field)s%(help_text)s</td></tr>',
> u'<tr><td colsp
> "2">%s</td></tr>', '</td></tr>', u'<br />%s', False)
> 178
> 179 def as_ul(self):
>
> c:\django\django\forms\forms.py in _html_output(self, normal_row,
> error_row, row_ender, help_text_html, errors_on_separate_row)
> 131 def _html_output(self, normal_row, error_row, row_ender,
> help_text_html, errors_on_separate_row):
> 132 "Helper function for outputting HTML. Used by as_table(),
> as_ul(), as_p()."
> --> 133 top_errors = self.non_field_errors() # Errors that should
> be displayed above all fields.
> 134 output, hidden_fields = [], []
> 135 for name, field in self.fields.items():
>
> c:\django\django\forms\forms.py in non_field_errors(self)
> 191 are none.
> 192 """
> --> 193 return self.errors.get(NON_FIELD_ERRORS,
> self.error_class())
> 194
> 195 def full_clean(self):
>
> AttributeError: 'CharField' object has no attribute 'get'
New description:
Given form as follows, as_table crashes
I expect this has to do with collisions to properties of Form and
variations of problems will probably happen with (errors, changed_data,
media)
{{{
#!python
class TestForm(forms.ModelForm):
errors = forms.CharField(widget=forms.HiddenInput)
class Meta:
model = MyModel
}}}
Stack trace
{{{
c:\django\django\forms\forms.py in as_table(self)
175 def as_table(self):
176 "Returns this form rendered as HTML <tr>s -- excluding the
<table></table>."
--> 177 return
self._html_output(u'<tr><th>%(label)s</th><td>%(errors)s%(field)s%(help_text)s</td></tr>',
u'<tr><td colsp
"2">%s</td></tr>', '</td></tr>', u'<br />%s', False)
178
179 def as_ul(self):
c:\django\django\forms\forms.py in _html_output(self, normal_row,
error_row, row_ender, help_text_html, errors_on_separate_row)
131 def _html_output(self, normal_row, error_row, row_ender,
help_text_html, errors_on_separate_row):
132 "Helper function for outputting HTML. Used by as_table(),
as_ul(), as_p()."
--> 133 top_errors = self.non_field_errors() # Errors that should
be displayed above all fields.
134 output, hidden_fields = [], []
135 for name, field in self.fields.items():
c:\django\django\forms\forms.py in non_field_errors(self)
191 are none.
192 """
--> 193 return self.errors.get(NON_FIELD_ERRORS,
self.error_class())
194
195 def full_clean(self):
AttributeError: 'CharField' object has no attribute 'get'
}}}
Comment:
Fixed description formatting.
--
Ticket URL: <http://code.djangoproject.com/ticket/8436#comment:1>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" 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-updates?hl=en
-~----------~----~----~----~------~----~------~--~---