1
0
mirror of https://github.com/django/django.git synced 2025-10-27 07:36:08 +00:00

Fixed #36295, Refs #24305 -- Allowed overriding GenericForeignKey fields on abstract models.

This commit is contained in:
Ahmed Nassar
2025-04-20 11:57:40 +02:00
committed by Sarah Boyce
parent 384cdf0f7a
commit 84e91262d6
3 changed files with 32 additions and 2 deletions

View File

@@ -348,7 +348,7 @@ class ModelBase(type):
new_class._meta.parents.update(base_parents)
# Inherit private fields (like GenericForeignKey) from the parent
# class
# class if they are not overridden.
for field in base._meta.private_fields:
if field.name in field_names:
if not base._meta.abstract:
@@ -361,7 +361,10 @@ class ModelBase(type):
base.__name__,
)
)
else:
elif (
field.name not in new_class.__dict__
and field.name not in inherited_attributes
):
field = copy.deepcopy(field)
if not base._meta.abstract:
field.mti_inherited = True