Opened 20 months ago

Closed 20 months ago

Last modified 20 months ago

#34431 closed Cleanup/optimization (fixed)

DateTimeField.input_formats change from Django 3.1 is documented improperly

Reported by: stefan6419846 Owned by: Edison Wang
Component: Documentation Version: 3.1
Severity: Normal Keywords:
Cc: Claude Paroz, Edison Wang Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

In https://github.com/django/django/commit/188b003014dc727ca22f7fafb21cf2fa0b3472d2, django.forms.fields.DateTimeField.input_formats has been changed to be a generator instead of the previous list. This type change does not seem to have been documented anywhere, leading to unexpected errors during migration and does not match the type of the input_formats for the other datetime-related fields.

Change History (8)

comment:1 by Mariusz Felisiak, 20 months ago

Cc: Claude Paroz added
Component: UncategorizedDocumentation
Triage Stage: UnreviewedAccepted
Type: UncategorizedCleanup/optimization

Thanks for the report. We should update the docs.

comment:2 by Edison Wang, 20 months ago

Owner: changed from nobody to Edison Wang
Status: newassigned

comment:4 by Edison Wang, 20 months ago

Cc: Edison Wang added

comment:5 by Edison Wang, 20 months ago

Has patch: set

Link to pull request: https://github.com/django/django/pull/16698

I also updated the documentation for TimeField and DateField because the input_formats attribute for both fields are also generators since they are lazily evaluated.

I believe that the changes made to django.forms.fields.DateTimeField.input_formats from https://github.com/django/django/commit/188b003014dc727ca22f7fafb21cf2fa0b3472d2 are redundant. The previous initialization is already lazily evaluated, so there is no need to include the class DateTimeFormatsIterator to define the generator. Should this part be reverted?

in reply to:  5 comment:6 by Mariusz Felisiak, 20 months ago

Patch needs improvement: set

I believe that the changes made to django.forms.fields.DateTimeField.input_formats from https://github.com/django/django/commit/188b003014dc727ca22f7fafb21cf2fa0b3472d2 are redundant. The previous initialization is already lazily evaluated, so there is no need to include the class DateTimeFormatsIterator to define the generator. Should this part be reverted?

get_format_lazy() doesn't support multiple settings so DateTimeFormatsIterator is necessary.

comment:7 by Mariusz Felisiak, 20 months ago

Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin

comment:8 by Mariusz Felisiak <felisiak.mariusz@…>, 20 months ago

Resolution: fixed
Status: assignedclosed

In cbcc1240:

Fixed #34431 -- Improved Date/DateTimeField/TimeField.input_formats docs.

comment:9 by Mariusz Felisiak <felisiak.mariusz@…>, 20 months ago

In 9ef2625c:

[4.2.x] Fixed #34431 -- Improved Date/DateTimeField/TimeField.input_formats docs.

Backport of cbcc1240e912cfc47cb6ea0c4fe6b4a48f36f7e2 from main

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