I'm trying to achive that such endpoint /api/messages/<str:email>/
will return a list of messages for given email.
So in my ViewSet I've created a function with @action
decorator
@action(
detail=False,
methods=["get"],
name="Get email messages",
url_path="<str:email>",
url_name="Email's messages"
)
def email_messages(self, request, email=None):
return Response({"aaa": email}, status=200)
But it seems that django doesn't resolve eg. this url: /api/messages/aaa/
(just for the test) and returns 404.
Even if I change url_path
to email
it returns 404 on /api/messages/email/
. It only works when I remove the url_path
kwarg from the params. Then it is accessible under /api/messages/email_messages
.
How can I achieve a working GET
on /api/messages/<str:email/
so that the email will be passed to the function?