DateTimeField, auto_now_add, and makemigrations

23 views
Skip to first unread message

Jim

unread,
Oct 19, 2016, 10:02:40 AM10/19/16
to Django users
Hello,

Having trouble with something on which the documentation seems clear to me.  I'd greatly appreciate any help. 

I wanted to add a field to a model showing when a user signed on.  I thought this is right.

      signup_datetime = models.DateTimeField(auto_now_add=True)  



But python3 ./manage.py makemigrations objected:
 
You are trying to add the field 'signup_datetime' with 'auto_now_add=True' to tootuser without a default; the database needs something to populate existing rows

Any suggestions?

(When I tried

signup_datetime = models.DateTimeField(default=datetime.datetime.now, blank=True)

it said this:

/usr/local/lib/python3.4/dist-packages/django/db/models/fields/__init__.py:1430: RuntimeWarning: DateTimeField TootUser.signup_datetime received a naive datetime (2016-10-19 13:48:14.145943) while time zone support is active.
  RuntimeWarning)

but honestly, I can't figure out what is wrong with the first try.)

Reply all
Reply to author
Forward
0 new messages