#33075 closed Bug (invalid)

'__date' returns None in MySQL while it returns date object in Sqlite3

Reported by: pikicode Owned by: nobody
Component: Database layer (models, ORM) Version: 3.2
Severity: Normal Keywords: mysql
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by pikicode)

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')\

The code just returns Nones in Mysql. But it returns date object with Sqlite

Change History (2)

comment:1 Changed 19 months ago by pikicode

Description: modified (diff)

comment:2 Changed 19 months ago by Mariusz Felisiak

Component: UncategorizedDatabase layer (models, ORM)
Keywords: mysql added
Resolution: invalid
Status: newclosed

When USE_TZ is True, fields are converted to the current time zone before filtering (see __date docs). This requires time zone definitions in the database. Please check that mysql_tzinfo_to_sql is loaded to the time zone tables.

Note: See TracTickets for help on using tickets.
Back to Top