Opened 3 years ago

Last modified 3 years ago

#33075 closed Bug

'__date' returns None in MySQL while it returns date object in Sqlite3 — at Version 1

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

Change History (1)

comment:1 by pikicode, 3 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top