Hi Daniel,

On 11/19/2014 08:58 AM, Daniel Grace wrote:
> On Wednesday, 19 November 2014 15:11:27 UTC, Carl Meyer wrote:
>     On 11/19/2014 08:07 AM, Daniel Grace wrote:
>     > I have already installed pytz (2014.17) and I have set
>     USE_TZ=True.  I
>     > don't use any naive datetimes in my application.  This error is
>     caused
>     > by something that the Django test command is doing automatically,
>     if you
>     > look at the traceback you will see that it is something to do with
>     > migrations.  I am using Django 1.7.
> 
>     What is the default value for your Flow.created field?
> 
> Hi Carl,
> I was not specifying one, so I changed my model and did a
> "makemigrations" and a "syncdb" :

"syncdb" is a deprecated alias for "migrate" - may as well start getting
used to doing "migrate" instead.

> class Flow(models.Model):
>     ref = models.CharField(max_length=32)
>     state = models.ForeignKey(State)
>     flow_type = models.ForeignKey(Type)
>     created = models.DateTimeField(db_index=True, auto_now_add=True,
> default=timezone.now)
>     modified = models.DateTimeField(db_index=True, auto_now=True,
> default=timezone.now)
>     version = models.IntegerField()
> 
> But I still get the exact same warning (see my original message in this
> thread) !

If you have `auto_now_add=True`, then you don't actually want a default
(it won't have any effect).

But based on your traceback, it seems like at some point in the past
when you made a migration, the field might have had a default value
which was a naive datetime. Is that possible?

It might be necessary to look through your existing migrations for this
app to find the culprit.

Carl

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to