Open
Description
If you have a GenericRelation field that uses a deferred string argument rather than an a class argument, documentation build fails with:
Extension error (sphinxcontrib_django.docstrings):
Handler <function improve_docstring at 0x00000123AE286EE0> for event 'autodoc-process-docstring' threw an exception (exception: 'str' object has no attribute '_meta')
Through the debugger, I narrowed the issue down to here, where the format string argument fails because field.model
is a string ("app2.ModelB"
in the example code below)
Example code:
# in app1/models.py
class ModelA(models.Model):
relation_field = GenericRelation(
"app2.ModelB",
)
# in app2/models.py
class ModelB(models.Model):
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
object_id = models.PositiveIntegerField(null=True)
content_object = GenericForeignKey()
I have a fix incoming that deals with this.