I have a model which has a date time field:
date = models.DateField(_("Date"), default=datetime.now())
When I check the app in the built in django admin, the DateField also has the time appended to it, so that if you try to save it an error is returned. How do I make the default just the date? (datetime.today() isn’t working either)
Your mistake is using the
datetimeclass instead of thedateclass. You meant to do this:If you only want to capture the current date the proper way to handle this is to use the
auto_now_addparameter:However, the modelfield docs clearly state that
auto_now_addandauto_nowwill always use the current date and are not a default value that you can override.