Skip to content

Custom Viewset: circular inheritance problems

Currently, to create a custom viewset, I extend LDPViewSet in views.py:

from djangoldp.views import LDPViewSet
from .models import CustomModel

class CustomViewSet(LDPViewSet):
   model = CustomModel

I then set view_set for my Model:

from djangoldp.models import Model
from .views import CustomViewSet

class CustomModel(Model):

    class Meta(Model.Meta):
        view_set = CustomViewSet

You can see how the issue of circular inheritance comes about easily with this design. It's often possible to get creative and import the CustomModel to the viewset at runtime, but not always, and not always cleanly