But when I wanted to create migrations I got:
{{{
$ python manage.py makemigrations users
It is impossible to add the field 'created_at' with 'auto_now_add=True' to
customuser without providing a default. This is because the database needs
something to populate existing rows.
1) Provide a one-off default now which will be set on all existing rows
2) Quit and manually define a default value in models.py.
Select an option: 2
}}}
Ok, according to this, I added a default as in
{{{
created_at = models.DateTimeField(auto_now_add=True, default=datetime.now)
}}}
but creating migrations still complain:
{{{
$ python manage.py makemigrations users
SystemCheckError: System check identified some issues:
ERRORS:
users.CustomUser.created_at: (fields.E160) The options auto_now,
auto_now_add, and default are mutually exclusive. Only one of these
options may be present.
}}}
That means, according to the message from manage.py:
- `auto_now`, `auto_now_add`, and `default` are mutually exclusive
- but at the same time, I need to add a default for `auto_now_add` to be
added
I am puzzled
--
Ticket URL: <https://code.djangoproject.com/ticket/35037>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Comment (by Norbert Preining):
What works is providing a one-off value by selection 1 in the first case.
--
Ticket URL: <https://code.djangoproject.com/ticket/35037#comment:1>
* status: new => closed
* resolution: => invalid
Comment:
Closing with invalid
--
Ticket URL: <https://code.djangoproject.com/ticket/35037#comment:2>