Opened 3 weeks ago
Closed 2 weeks ago
#35880 closed Bug (fixed)
Form Field.requried docs invalid example due to CharField.strip
Reported by: | Antoliny | Owned by: | Antoliny |
---|---|---|---|
Component: | Documentation | Version: | 5.1 |
Severity: | Normal | Keywords: | Form Fields Document |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Hello!
I created an issue by finded the wrong parts and the good parts when improved in the Form fields document.
- Field.requried section invalid example.
>>> from django import forms >>> f = forms.CharField() ... >> f.clean(" ") ' '
In the example passed a character string with spaces as a factor in the clean method to a CharField instance.
This part is cleared space by CharField's to_python method, result is an empty_value so occur validation error.
class CharField(Field): ... def to_python(self, value): """Return a string.""" if value not in self.empty_values: value = str(value) if self.strip: value = value.strip() # before value: " ", after value: "" if value in self.empty_values: return self.empty_value return value ...
However, in the current document, a string containing spaces seems to pass through the clean method.
2. Field.label section unclear part -> ("outputting forms as HTML" above)
It is unclear what " 'Outputting forms as HTML' above" refers to in the Field label section.
This part probably means the "Outputting forms as HTML" section of the Forms API Document.
3. Consistency "fallback" and link message
This part is very trivial :)
The word "fallback" used in the field initial section are two values "fallback" and "fall back".
"Also note that initial values are not used as "fallback" ... --- >>> f.is_valid() False # The form does *not* fall back to using .... ...
I think it would be better to include documentation in the message set as a link.
(Like the link message used in validators section.)
``localize`` ------------ .. attribute:: Field.localize The ``localize`` argument enables the localization of form data input, as well as the rendered output. See the :doc:`format localization </topics/i18n/formatting>` documentation for # --> See the :doc:`format localization documentation</topics/i18n/formatting> ` for more information.
Change History (11)
comment:1 by , 3 weeks ago
Owner: | set to |
---|---|
Status: | new → assigned |
comment:2 by , 3 weeks ago
Has patch: | set |
---|
comment:3 by , 3 weeks ago
comment:4 by , 3 weeks ago
Description: | modified (diff) |
---|
comment:5 by , 2 weeks ago
Description: | modified (diff) |
---|---|
Summary: | Consistency and improvements to the form fields document. → Form Field.requried docs invalid example due to CharField.strip |
Triage Stage: | Unreviewed → Accepted |
Type: | Cleanup/optimization → Bug |
comment:6 by , 2 weeks ago
Description: | modified (diff) |
---|
comment:7 by , 2 weeks ago
2 and 3 can be done without a ticket, 1 is an issue here which I have added a comment on your patch
comment:8 by , 2 weeks ago
Patch needs improvement: | set |
---|
comment:9 by , 2 weeks ago
Patch needs improvement: | unset |
---|
comment:10 by , 2 weeks ago
Triage Stage: | Accepted → Ready for checkin |
---|
PR