Fixed default value provided issue with Django

2019-08-18 07:34发布

问题:

This is my model:

created_date = models.DateTimeField(default=datetime.datetime.now)

after I run it.I receives the following error:

article.Article.publish_date: (fields.W161) Fixed default value provided. HINT: It seems you set a fixed date / time / datetime value as default for this field. This may not be what you want. If you want to have the current date as default, use django.utils.timezone.now

While I replace the code like this:

created_date = models.DateTimeField(default=django.utils.timezone.now)

it still remains me :NameError: name 'django' is not defined

Any friend can help with this?