mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Fixed #30602 -- Made Extract raise ValueError when using unsupported lookups for DurationField.
This commit is contained in:
committed by
Mariusz Felisiak
parent
7a42cfcfdc
commit
402e6d292f
@@ -73,6 +73,14 @@ class Extract(TimezoneMixin, Transform):
|
||||
raise ValueError(
|
||||
"Cannot extract time component '%s' from DateField '%s'. " % (copy.lookup_name, field.name)
|
||||
)
|
||||
if (
|
||||
isinstance(field, DurationField) and
|
||||
copy.lookup_name in ('year', 'iso_year', 'month', 'week', 'week_day', 'quarter')
|
||||
):
|
||||
raise ValueError(
|
||||
"Cannot extract component '%s' from DurationField '%s'."
|
||||
% (copy.lookup_name, field.name)
|
||||
)
|
||||
return copy
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user