Django 1.8 now has some problem detection for models, which is nice. However, for one warning that it is giving me, I understand the problem, but I don't understand how the hint that it is giving me is any better.
This is my (bad) model field:
my_date = DateField(default=datetime.now())
and it's easy to see why that's bad. But this is the hint it's giving me:
MyMoel.my_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`
So, it says to use timezone.now
, but how is that any better than datetime.now
? They're both "fixed default" values... timezone.now
just returns a datetime instance, which is a fixed value...
I suspect that it actually wants me to insert some sort of flag that says "use timezone.now
later". But that's not what the hint says... so what is that flag?
datetime.now
ortimezone.now
, or anything that is a function that returns a date)? – Forbidding