django-json-api/django-rest-framework-json-api

ResourceRelatedField with multiple related_link_url_kwarg paramaters for nested resources

Marclev78 opened this issue · 0 comments

Description of feature request

I'm not sure if this is a feature request, or a bug report, or simply my not understand the framework correctly.

It seems to be impossible to use ResourceRelatedField objects to refer to nested resources.

For example, in my model I have something like:

store/123/catalogues/222/categories

There are two ID path parameters in that URl. So in my catalogue serializer I want to do something like this:

    categories = ResourceRelatedField(
        queryset=Category.objects,
        many=True,
        related_link_view_name='catalogue-categories-list',
        related_link_url_kwargs=['store_id', catalogue_pk']
    )

but I can't see any way to do that, meaning the serializer errors when it tries to use the view. Am I missing something or is it not possible to use ResourceRelatedFields for these sorts of nested resources?

I couldn't see this covered in the documentation. Is there an alternative way I should be doing it?