I am writing a simple game in Django, all of things were right, but suddenly..., I was encountered by following error:
I had a similar thing. Delete all migrations from your folder /migrations and then run python manage.py makemigrations and then python manage.py migrate. This worked for me.
As far as I understand, you already have a database which already has some "Move" entries in it.
If you add a column in a table which already has data in it, you'll need to provide a default value for that column, that the migration will set to all existing entries in the DB for the involved table (otherwise such entries will be invalid, unless null=True is specified as kwarg, if I remember correctly)
Furthermore, it is possible (happens to me ALL THE TIME), that you will need to set, in settings.py, the DATE_INPUT_FORMATS and the DATETIME_INPUT_FORMATS variables, accordingly to your locale and the way you're used to type dates. (See https://docs.djangoproject.com/en/1.7/ref/settings/#date-input-formats)
An example (In Italy, we have DD/MM/YYYY format):
DATE_INPUT_FORMATS = ( "%d/%m/%Y", )
DATETIME_INPUT_FORMATS = ( "%d/%m/%Y %H:%M", )
You django configuration is expecting the following format instead:
YYYY-MM-DD HH:MM[:ss[.uuuuuu]][TZ]
(Stuff inside the square brackets is optional)
Edit: the auto_now_add kw arg tells that the field value should be set to "now" when adding (and not updating..) an entry
It asked me for entering a default value for DateTimeField()
It is doing this because you have not specified a default, and the field is not optional. Since its a destructive change, you have to provide a default value.
You probably just hit enter and hence the exception, since a blank string is not a valid entry for DateTimeField
.
The solution is to run migrate again, and this time provide a valid date and time string; which will be used for all existing rows in your database; example of a valid format is 2015-02-12 00:00
Also, if you're not afraid of getting your hands a little dirty, looking through the migrations files in that folder and finding the specific invalid field did it for me. Deleting all the migrations threw up a few errors for me.