﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
36295	Unable to Override GenericForeignKey in Inherited Abstract Class	Gagan Deep	Ahmed Nassar	"Attempting to override a GenericForeignKey field in an inherited abstract model does not work as expected. According to the [https://docs.djangoproject.com/en/5.2/topics/db/models/#field-name-hiding-is-not-permitted Django documentation], it should be possible to hide a field inherited from an abstract model by setting it to `None`. 

However, this does not seem to work for GenericForeignKey.

I have created a [https://github.com/pandafy/django-genericforeignkey-inheritance Django project] for quick testing. 

**Steps to replicate:**

1. Define an abstract model with a GenericForeignKey field.
2. Create another abstract model that inherits from the first and attempt to override the GenericForeignKey field by setting it to None.
3. Define a concrete model that inherits from the second abstract model.

**Code Example**
{{{
from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType
from django.db import models


class AbstractBaseModel(models.Model):
    content_type = models.ForeignKey(
        ContentType, on_delete=models.SET_NULL, null=True, blank=True
    )
    object_id = models.PositiveIntegerField(null=True, blank=True)
    related_object = GenericForeignKey(""content_type"", ""object_id"")
    description = models.TextField(null=True, blank=True)

    class Meta:
        abstract = True


class AbstractDerivedModel(AbstractBaseModel):
    related_object = None  # Override GenericForeignKey
    description = None

    class Meta:
        abstract = True


class ConcreteEntity(AbstractDerivedModel):
    name = models.CharField(max_length=255)

    class Meta:
        abstract = False
}}}

**Expected Behavior:**

The `related_object field` in `AbstractDerivedModel` should override the `GenericForeignKey` in `AbstractBaseModel`, making it effectively absent in `ConcreteEntity`.

**Actual Behavior:**

Django still considers the GenericForeignKey field from AbstractBaseModel when defining ConcreteEntity, leading to unexpected behavior.


**Additional Notes:**

* Overriding standard model fields with `None` works as expected, but `GenericForeignKey` does not follow the same behavior (`description` field in the above example).
* There is no explicit mention in the documentation that GenericForeignKey is exempt from the field-hiding mechanism. I checked the following pages: 
    * https://docs.djangoproject.com/en/5.1/ref/contrib/contenttypes/
    * https://docs.djangoproject.com/en/5.2/topics/db/models/#field-name-hiding-is-not-permitted
"	Bug	closed	contrib.contenttypes	5.2	Normal	fixed		Gagan Deep	Ready for checkin	1	0	0	0	0	0
