Created
May 29, 2014 08:38
-
-
Save nacady/8dd5cab2f749d1589f1e to your computer and use it in GitHub Desktop.
SplitDateTimeField in modelform django
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DateTimeField(models.DateTimeField): | |
def formfield(self, **kwargs): | |
defaults = {'form_class': forms.SplitDateTimeField, | |
'input_date_formats': ['%y/%m/%d']} | |
defaults.update(kwargs) | |
return super(DateTimeField, self).formfield(**defaults) | |
class Model(models.Model): | |
date = DateTimeField() | |
class Form(forms.ModelForm): | |
class Meta: | |
model = Model |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment