Fixed Default Value Provided Issue With Django
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) Fix
Solution 1:
You can try this.
from django.utils import timezone
today = timezone.now
class Myclass(models.Model):
created_date = models.DateTimeField(default=today)
Solution 2:
This is default for now. It will add the time object got created.
created_date = models.DateTimeField(auto_now_add=True)
Post a Comment for "Fixed Default Value Provided Issue With Django"