Ticket #19431: modelform_qs_initial_datetime.patch

File modelform_qs_initial_datetime.patch, 887 bytes (added by aleray, 12 years ago)
  • django/contrib/admin/options.py

    diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
    index c48ffa6..ca46299 100644
    a b  
    11from functools import update_wrapper, partial
    22import warnings
    33
     4import dateutil.parser
     5
    46from django import forms
    57from django.conf import settings
    68from django.forms.formsets import all_valid
    class ModelAdmin(BaseModelAdmin):  
    10551057                    continue
    10561058                if isinstance(f, models.ManyToManyField):
    10571059                    initial[k] = initial[k].split(",")
     1060                elif isinstance(f, models.DateTimeField):
     1061                    initial[k] = dateutil.parser.parse(initial[k])
    10581062            form = ModelForm(initial=initial)
    10591063            prefixes = {}
    10601064            for FormSet, inline in zip(self.get_formsets(request), inline_instances):
Back to Top