#9739: Admin does not correctly prefill DataTimeField from URL
-------------------------------+-----------------------------------------
     Reporter:  gilhad         |                    Owner:  Ridley Larsen
         Type:  Bug            |                   Status:  assigned
    Component:  contrib.admin  |                  Version:  1.0
     Severity:  Normal         |               Resolution:
     Keywords:                 |             Triage Stage:  Accepted
    Has patch:  1              |      Needs documentation:  0
  Needs tests:  0              |  Patch needs improvement:  1
Easy pickings:  0              |                    UI/UX:  0
-------------------------------+-----------------------------------------

Comment (by Baptiste Mispelon):

 Just a quick update to note that this issue still happens in the current
 master (e8fcdaad5c428878d0a5d6ba820d957013f75595) with the following error
 message:
 {{{
 'str' object has no attribute 'utcoffset'
 }}}

 However there's been a bit of progress as there's now a documented way to
 populate a form using the data from `request.GET` with
 `ModelAdmin.get_changeform_initial_data()` [1] (introduced in 1.7).

 Interestingly, the current implementation of `get_changeform_initial()`
 has a special case to handle `ManyToManyField` [2]but that special case is
 neither documented nor tested (removing it doesn't trigger any test
 failure).
 I also find it curious that the current implementation doesn't seem to
 interact at all with the form layer (it only interacts with the model
 layer, checking that the keys of `request.GET` correspond to existing
 fields). Forms (and widgets) tend to be good at converting plain strings
 to useful python objects so maybe it could help resolve this ticket
 without hardcoding a bunch of special cases?

 [1]
 
https://docs.djangoproject.com/en/2.2/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_changeform_initial_data
 [2]
 
https://github.com/django/django/blob/e8fcdaad5c428878d0a5d6ba820d957013f75595/django/contrib/admin/options.py#L1495

-- 
Ticket URL: <https://code.djangoproject.com/ticket/9739#comment:24>
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/064.a2874f4942c7c11dd6b4114114c8f970%40djangoproject.com.

Reply via email to