0👍
✅
To use the path params added in the url pattern, you must add the **kwargs
as an extra parameter to the get()
method. Your view should look like this:
class UserView(APIView):
def get(self, request, **kwargs):
...
author = kwargs.get('author', None)
1👍
get()
method should accept url parameters too, you can use *args
and **kwargs
syntax to make sure it works no matter how you name your parameter:
class UserView(APIView):
def get(self, request, *args, **kwargs):
...
author = self.kwargs.get('author', None)
- [Answered ]-What exactly does the models.Model argument refer to in models.py?
- [Answered ]-Dynamic Search? how?
Source:stackexchange.com