[Answered ]-Drf-spectacular issue with filterset_fields

1👍

Turns out it was a Viewset that was trying to apply filterset_fields on a subModel that did not directly contain those fields, but rather referenced by ForeignKey on another Parent Model. While I thought these filters were working as expected, I think the actual filtering on those fields was being performed by middleware in this case.

Removing the fields from the Viewset allows the schema to be generated with no issue. I am able to access the /docs page fully rendered and /schema endpoint working. Very impressed with drf-spectacular thus far.

example model:

class DataSteam(models.Model):
    """Class for DataSteam Model."""
    client = models.CharField(max_length=200)
    tenant_id = models.CharField(max_length=200)
    subtenant_id = models.CharField(max_length=200)
    data_stream_id = models.CharField(max_length=200)

class subModel(models.Parent):
    """Class for storing linked datastream records."""
    ds = models.ForeignKey(DataStream, on_delete=models.CASCADE) 

Leave a comment