{{{Model.objects.values('some_datetime_field__date',) }}} returns None in
MYSQL
{{{
class Inbound(models.Model):
effective_date = models.DateTimeField(null=False, blank=True)
number = models.IntegerField()
# other fields.
daily_changes = Inbound.objects.all().values('effective_date__date')\
.annotate(total_change=Sum('number')).
Inbound.objects.values('effective_date__date')
}}}
just returns Nones in Mysql
--
Ticket URL: <https://code.djangoproject.com/ticket/33075>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Old description:
> database: mysql 5.7
> django version: 3.2
> python version: 3.8.1
>
> {{{Model.objects.values('some_datetime_field__date',) }}} returns None in
> MYSQL
>
>
> {{{
> class Inbound(models.Model):
> effective_date = models.DateTimeField(null=False, blank=True)
> number = models.IntegerField()
> # other fields.
>
> daily_changes = Inbound.objects.all().values('effective_date__date')\
> .annotate(total_change=Sum('number')).
> Inbound.objects.values('effective_date__date')
> }}}
>
>
> just returns Nones in Mysql
New description:
database: mysql 5.7
django version: 3.2
python version: 3.8.1
{{{Model.objects.values('some_datetime_field__date',) }}} returns None in
MYSQL
{{{
class Inbound(models.Model):
effective_date = models.DateTimeField(null=False, blank=True)
number = models.IntegerField()
# other fields.
daily_changes = Inbound.objects.all().values('effective_date__date')\
.annotate(total_change=Sum('number')).
Inbound.objects.values('effective_date__date')
}}}
The code just returns Nones in Mysql. But it returns date object with
Sqlite
--
--
Ticket URL: <https://code.djangoproject.com/ticket/33075#comment:1>
* keywords: => mysql
* resolution: => invalid
* status: new => closed
* component: Uncategorized => Database layer (models, ORM)
Comment:
When `USE_TZ` is `True`, fields are converted to the current time zone
before filtering (see
[https://docs.djangoproject.com/en/3.2/ref/models/querysets/#date __date
docs]). This requires
[https://docs.djangoproject.com/en/3.2/ref/models/querysets/#database-
time-zone-definitions time zone definitions in the database]. Please check
that `mysql_tzinfo_to_sql` is loaded to the time zone tables.
--
Ticket URL: <https://code.djangoproject.com/ticket/33075#comment:2>