I ran into the same issue, it appears when you have a model form with a field that is the same name as in the model (in this case a GFK) it takes the read-only from the model field instead of the form field. This used to work fine in Django 5.0 and earlier but broke in 5.1. For example we have:
class EventRuleForm():
...
action_object = forms.CharField(
label=_('Action object'),
required=True,
help_text=_('Webhook name or script as dotted path module.Class')
)
In this case we handle action_object in the clean method and use it to set instance.action_object. But now in Django 5.1 it throws the django.core.exceptions.FieldError shown above.
Not sure if this is an undocumented change on purpose or a bug. Will look at getting a smaller repro scenario together.
I ran into this as well. Looks like it might be caused by refactoring GFK to inherit from the base Field class. As part of the migration in Fixed #35224 -- Made GenericForeignKey inherit from Field. · django/django@6002df0 · GitHub, the self.editable is hardcoded to False. Hard to tell if it was intentional, but my guess given this used to work fine is that it was an oversight leading to accidental breaking change.