Based on this idea I made new db.fields class EuDateField:
mydbfields.py
from django import forms
from django.forms.fields import DEFAULT_DATE_INPUT_FORMATS
from django.db import models
class EuDateFormField(forms.DateField):
def __init__(self, *args, **kwargs):
kwargs.update({'input_formats': ("%d.%m.%Y",)+DEFAULT_DATE_INPUT_FORMATS})
super(EuDateFormField, self).__init__(*args, **kwargs)
class EuDateField(models.DateField):
def formfield(self, **kwargs):
kwargs.update({'form_class': EuDateFormField})
return super(EuDateField, self).formfield(**kwargs)
Note that it adds my format (e.g. 31.12.2007) to existing "standard" django formats at first place.
Usage:
from mydbfields import EuDateField
class Person(models.Model):
...
birthday = EuDateField("Birthday", null=True, blank=True, help_text="")
In my case this renders good in admin, but most probably will in ModelForm too (haven't tried it).
My django version is:
>>> import django
>>> django.get_version()
u'1.1 alpha 1 SVN-10105'