Django DateField default options

django, django-models, python

Solution

Your mistake is using the `datetime` class instead of the `date` class. You meant to do this:

from datetime import date
date = models.DateField(_("Date"), default=date.today)

If you only want to capture the current date the proper way to handle this is to use the `auto_now_add` parameter:

date = models.DateField(_("Date"), auto_now_add=True)

However, the modelfield docs clearly state that `auto_now_add` and `auto_now` will always use the current date and are not a default value that you can override.

Problem

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)

Original source