Opened 53 minutes ago
#37323 new Bug
Reading a DateField from a column of type timestamp produces python datetime.datetime
| Reported by: | uli123abc | Owned by: | |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | |
| Severity: | Normal | Keywords: | DateField, timestamp, date, datetime |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Current behavior:
According to documented behavior [1], DateField should represent a datetime.date object. If however the database column (Postgresql) is of type timestamp [2], reading the field will produce a datetime.datetime object.
Expected behavior:
The ORM should warn about a type mismatch or cast the database value to a datetime.date object.
[1] https://docs.djangoproject.com/en/6.1/ref/models/fields/#datefield
[2] https://www.postgresql.org/docs/current/datatype-datetime.html
Note:
See TracTickets
for help on using tickets.