nested_urls enforcing the parent's ViewSet, and messiness in custom implementation
Scenario: I would like my model to use a custom view_set
. I have to do something like below:
class I18nLDPViewSet(LDPViewSet):
# custom methods..
@classonlymethod
def nested_urls(cls, nested_field, **kwargs):
return I18nLDPNestedViewSet.nested_urls(nested_field, **kwargs)
class I18nLDPNestedViewSet(LDPNestedViewSet, I18nLDPViewSet):
pass
It's a little messy that I need to override the LDPNestedViewSet
as well and break into the nested_urls
computation to change it
More critically, the resulting behaviour of this is that:
- when I access my model via the
nested_field
of another, e.g.http://localhost/anothermodels/1/mymodels/
, my customViewSet
is not applied, it is assigned by theViewSet
class of the parent, see this line - when I access another model via the
nested_field
of mine, e.g.http://localhost/mymodels/1/anothermodels/
, the "mymodel ViewSet` is applied, rather than that of the child, for the same reason
I believe that nested_urls
should be called on the view_set
from the child model, not that of the parent