I want the Django model to have a date field in which year, month and day are optional. An approximate value may be general as 2008or as specific as May 10, 2008. Is it possible to define a DateFieldto behave this way? Or is it better for me to define year / month / day as separate integers, for example?
2008
May 10, 2008
DateField
model Book(models.Model): publication_year = models.IntegerField(blank=True, null=True) publication_month = models.IntegerField(blank=True, null=True) publication_day = models.IntegerField(blank=True, null=True)
django-date-extensions at https://github.com/dracos/django-date-extensions (for me, just for this purpose) includes an ApproximateDate object to handle dates that may not be a month or a day.
Django DateTimeField python datetime.datetime, , :
datetime.datetime(year, month, day[, hour[, minute[, second[, microsecond[, tzinfo]]]]])
Django DateTimeField , , .