mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Refs #31486 -- Removed ability to pass unsaved model instances to related filters.
Per deprecation timeline.
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
import warnings
|
||||
|
||||
from django.db.models.lookups import (
|
||||
Exact,
|
||||
GreaterThan,
|
||||
@@ -9,7 +7,6 @@ from django.db.models.lookups import (
|
||||
LessThan,
|
||||
LessThanOrEqual,
|
||||
)
|
||||
from django.utils.deprecation import RemovedInDjango50Warning
|
||||
|
||||
|
||||
class MultiColSource:
|
||||
@@ -45,14 +42,7 @@ def get_normalized_value(value, lhs):
|
||||
|
||||
if isinstance(value, Model):
|
||||
if value.pk is None:
|
||||
# When the deprecation ends, replace with:
|
||||
# raise ValueError(
|
||||
# "Model instances passed to related filters must be saved."
|
||||
# )
|
||||
warnings.warn(
|
||||
"Passing unsaved model instances to related filters is deprecated.",
|
||||
RemovedInDjango50Warning,
|
||||
)
|
||||
raise ValueError("Model instances passed to related filters must be saved.")
|
||||
value_list = []
|
||||
sources = lhs.output_field.path_infos[-1].target_fields
|
||||
for source in sources:
|
||||
|
||||
Reference in New Issue
Block a user