I have this field in my model created_at = models.DateTimeField( auto_now_add = True )
When I try to make migrations I get an error:
You are trying to add the field 'created_at' with 'auto_now_add=True' to user wi
thout a default; the database needs something to populate existing rows.
1) Provide a one-off default now (will be set on all existing rows)
2) Quit, and let me add a default in models.py
I tried to set the default value but it says default
and auto_now_add
are mutually exclusive. Of course I could just use default without auto_now_add
but I want to know why this error pops up. Did I miss something?
created_at
value.auto_now_add
?timezone.now()
. Then existing rows are populated with the current timestamp.