Context
I have two viewsets, with their own routers to automatically generate the URLs from them :
- ModelAViewset
- ModelBViewset
For now, only the ModelAViewset details can be access through the following URL :
{root_url}/model-a/<slug>
With '<slug>
' being the ModelA 'slug' field, as a lookup_field.
I am trying to figure out a way to build a route towards ModelBViewset detail as follows : {root_url}/model-a/<model_a_slug>/model-b/<model_b_pk>
Questions
- Is there a way to use a more explicit lookup_field value, dynamically based on the model name ? Like this :
{root_url}/model-a/<model_a_slug>
Note : To keep it simple in the model, I would rather like to leave the 'slug' field name of ModelA as is
Based on Viewsets and Routers, is there a way to access the ModelBViewset details through a multi lookup_fields ? With an URL like :
{root_url}/model-a/<model_a_slug>/model-b/<model_b_pk>
Thanks, by advance