Opened 11 years ago
Closed 11 years ago
#22475 closed Bug (needsinfo)
model change with DateTime field
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Migrations | Version: | 1.7-beta-1 |
Severity: | Normal | Keywords: | datetime |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I created a Model class with several field. next I added a models.DateTimeField field.
Next I just
python manage.py makemigrations [OK]
next I tried with:
python manage.py migrate
but I received the following error:
field=models.DateTimeField(default=date(2014, 4, 18)),
NameError: name 'date' is not defined
I see in the migration file the import to datetime is present:
import datetime
but in the line where is defined the date is missing datetime.date
field=models.DateTimeField(default=datetime.date(2014, 4, 18)),
I modified on this way and now it works.
This looks like #22363 to me. Could confirm your default date was specified as a one-off default when you created the migration?
If that's the case could you try reproducing against the master branch.