Opened 2 weeks ago
Last modified 2 weeks ago
#35413 new Cleanup/optimization
FieldError: Unsupported lookup error message can be confusing.
Reported by: | Alex | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 5.0 |
Severity: | Normal | Keywords: | |
Cc: | Alex | Triage Stage: | Accepted |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
On these example queries on DateTimeFields:
TestModel.objects.filter(created_at__gt__foo='2024-01-01') TestModel.objects.filter(created_at__gt__='2024-01-01') # I'm a bit surprised this one also has the same message. TestModel.objects.filter(created_at__gt__lt='2024-01-01')
The error message is this
django.core.exceptions.FieldError: Unsupported lookup 'gt' for DateTimeField or join on the field not permitted, perhaps you meant gt or gte?
The error message should clarify better the issue.
Change History (1)
comment:1 by , 2 weeks ago
Summary: | FieldError: Unsupported lookup error message can be confusing on DateTimeField → FieldError: Unsupported lookup error message can be confusing. |
---|---|
Triage Stage: | Unreviewed → Accepted |
Type: | Bug → Cleanup/optimization |
Note:
See TracTickets
for help on using tickets.
Replicated, this is also true of other fields.
I agree that saying something like
Unsupported lookup 'gt__foo'
,Unsupported lookup 'gt__'
, andUnsupported lookup 'gt__lt'
would be clearer.