10

Is there a method, or an attribute in request object that I can access to return me the URL exactly as the client requested? With the query params included?

I've checked request.build_absolute_uri after looking at this question but it just returns the URL without the query params.

I need the URL because my API response returns the URL for the "next page" of results. I could build it from the query_params attributes, but this view takes a lot of query params and some exclude others, so having access to the request url would save me a lot of pain.

2
  • 2
    You want request.get_full_path() Commented Aug 18, 2020 at 15:25
  • YES! Thank you. Do you mind submitting as an answer so I can accept it? Commented Aug 18, 2020 at 16:00

1 Answer 1

16

To get full path, including query string, you want request.get_full_path()

Sign up to request clarification or add additional context in comments.

1 Comment

This also works in serializer's create() as self.context['request'].get_full_path()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.