#33602: when use date_hierarchy in admin, it report a error. django 3.2.12,
mysql-connector-python8.0.28, mysql server 8.0.28
-----------------------------------------+------------------------
Reporter: Eric Pan | Owner: nobody
Type: Uncategorized | Status: new
Component: contrib.admin | Version: 3.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
\site-packages\django\db\backends\mysql\operations.py line 58
def date_trunc_sql(self, lookup_type, field_name, tzname=None):
field_name = self._convert_field_to_tz(field_name, tzname)
fields = {
'year': '%%Y-01-01',
'month': '%%Y-%%m-01',
} # Use double percents to escape.
the problem is here.
'year': '%%Y-01-01',
'month': '%%Y-%%m-01',
this will generate the sql.
SELECT DISTINCT CAST(DATE_FORMAT([table name], '%%Y-01-01') AS DATE) AS
`datefield
the format ''%%Y-01-01'' is not right for mysql.
--
Ticket URL: <https://code.djangoproject.com/ticket/33602>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107017fc5e454b7-7d7418b0-3079-4ef7-a1a8-3ae7616088a1-000000%40eu-central-1.amazonses.com.