Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get full request URL from inside APIView in Django REST Framework

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.

like image 841
Justcurious Avatar asked Aug 18 '20 15:08

Justcurious


1 Answers

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

like image 82
GAEfan Avatar answered Oct 12 '22 11:10

GAEfan