Open samamorgan opened 1 year ago
I found a workaround for this, but it's stinky. I'm still of the opinion that object_id
should be a GenericForeignKey
.
from django.contrib.contenttypes.admin import (
GenericInlineModelAdminChecks,
GenericTabularInline,
)
from easyaudit.models import CRUDEvent
class CRUDEventGenericCheck(GenericInlineModelAdminChecks):
"""Override check against `ct_fk_field`.
easyaudit uses CharField instead of GenericForeignKey for `ct_fk_field`
"""
def _check_relation(self, obj, parent_model):
errors = super()._check_relation(obj, parent_model)
for error in list(errors):
if error.msg == "'easyaudit.CRUDEvent' has no GenericForeignKey.":
errors.remove(error)
return errors
class CRUDEventInline(GenericTabularInline):
model = CRUDEvent
checks_class = CRUDEventGenericCheck
The way
CRUDEvent
is currently designed prevents generic inlines from functioning. Currently,object_id
is aCharField
. I'd propose that this be changed to aGenericForeignKey
so built-in Django functionality works as expected.Expected to work:
Error: