Extension error:
Handler <function improve_docstring at 0x7ff688d2c7b8> for event 'autodoc-process-docstring' threw an exception (exception: 'GenericForeignKey' object has no attribute 'primary_key')
from django.contrib.contenttypes.fields import GenericForeignKey
class MyModel(models.Model):
user = ForeignKey(User, ...)
object = GenericForeignKey('content_type', 'object_pk')
...
if isinstance(field, models.fields.reverse_related.ForeignObjectRel):
# do stuff
else:
# This means the field is either a normal field or a forward related field
# If the field is a primary key, include a notice
primary_key = "Primary key: " if field.primary_key else ""
field_verbose_name = force_str(field.verbose_name)
# Make the first letter upper case while leave the rest unchanged
# (str.capitalize() would make the rest lower case, e.g. ID => Id)
verbose_name = (
primary_key + field_verbose_name[:1].upper() + field_verbose_name[1:]
)
help_text = force_str(field.help_text)
I suppose an extra type check or exception handler is needed.