how to show relative URLs instead full url in payload #923
Replies: 4 comments
-
In exceptional cases relative urls might make sense but absolute urls are recommend by DRF see here This said you can overwrite This could look like this (just from the top ofof my head without any testing): def get_url(self, name, view_name, kwargs, request):
return super().get_url(name, view_name, kwargs, None) Does this work? |
Beta Was this translation helpful? Give feedback.
-
@sliverc no, I added this in my view but still the same. we need relative URLs in payload because our APIs are behind API-gateway. |
Beta Was this translation helpful? Give feedback.
-
@sliverc |
Beta Was this translation helpful? Give feedback.
-
I was thinking you are using relationship view where get_url would need to be overwritten as well. But of course you also need to do that for |
Beta Was this translation helpful? Give feedback.
-
I am having trouble showing relative links (self, related).
in payload it's always giving me a full URL like
http://localhost:8000/modules/3
, what I want is/modules/3
instead showing full URL.how can I achieve it?
Beta Was this translation helpful? Give feedback.
All reactions