[Django]-Django-rest-framework multiple url arguments

8👍

You can use the username in the url. For that to work you’ll have to first find the user manually and then use its id to find the Example object:

def get_object(self):
    username = self.kwargs.get('username')
    slug = self.kwargs.get('slug')

    # find the user
    user = User.objects.get(username=username)

    return Example.objects.get(user=user.id, slug=slug)
👤xyres

Leave a comment