MattBroach / DjangoRestMultipleModels

View (and mixin) for serializing multiple models or querysets in Django Rest Framework
MIT License
549 stars 67 forks source link

AssertionError: 'ViewSet' should either include a `serializer_class` attribute, or override the `get_serializer_class()` method. #50

Closed Naveenkorkopp closed 3 years ago

Naveenkorkopp commented 3 years ago

drf-yasg package when /swagger is loaded for FlatMultipleModelAPIView , this says AssertionError as 'ViewSet' should either include a serializer_class attribute, or override the get_serializer_class() method.

As django-rest-multiple-models needs querylist and not queryset.. So serializer_class cannot be specified

MattBroach commented 3 years ago

Because django-rest-multiple-models using it's own serialization path, any library that requires or edits the normal get_serializer_class method is going to raise that error. You'll likely have to override the get_serializer_class method on this view in order for it to talk to drf-yasg properly. Unfortunately, this is somewhat beyond the scope of this library (there are too many third-party libraries out there for me to be able to manage integrations which each one), so I'm going to close this issue drf-yasg has a note in its docs with some ideas on how to fix issues like this one -- I'd recommend you start there.