#32924: Move special-case logic in BoundField.initial() to
BaseForm.get_initial_for_field()
-------------------------------------+-------------------------------------
               Reporter:  Chris      |          Owner:  Chris Jerdonek
  Jerdonek                           |
                   Type:             |         Status:  assigned
  Cleanup/optimization               |
              Component:  Forms      |        Version:  dev
               Severity:  Normal     |       Keywords:
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 This is another follow-up to ticket #32920.

 Currently, `BoundField.initial()` has logic to special-case `time` and
 `datetime` objects:
 
https://github.com/django/django/blob/f5669fd7b568cf8a3eda1e65c1c6fb583c7b177d/django/forms/boundfield.py#L217-L219
 I noticed that this logic can be moved to
 `BaseForm.get_initial_for_field()`, and in particular under the `if
 callable(value)` block:
 
https://github.com/django/django/blob/f5669fd7b568cf8a3eda1e65c1c6fb583c7b177d/django/forms/forms.py#L496-L497

 Eventually, I think it could make sense to go further and move some of
 this logic to a new method of the `Field` class, which could permit the
 special-casing to be handled by overriding in sub-classes that use times
 and datetimes.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32924>
Django <https://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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/052.e7c2c9eeb9153b52e7de617feff1db84%40djangoproject.com.

Reply via email to