Reputation: 12627
I have a view which accepts GET params (accessible via the request.GET
and that are present in the uri)
Inside the view I want to get the exact uri that was used to call that view maintaining order
Example:
If a call was made to http://best.site.ever/?this=that&that=this
I want to be able to fetch it in the view
def best_view_ever(request):
calling_uri = get_calling_uri(request)
calling_uri # this should be http://best.site.ever/?this=that&that=this
Is this achievable in any way?
Upvotes: 2
Views: 405
Reputation: 3721
build_absolute_uri
method of request object would be helpful here
def get_calling_uri(request):
return request.build_absolute_uri()
def best_view_ever(request):
calling_uri = get_calling_uri(request)
print calling_uri # this should be http://best.site.ever/?this=that&that=this
Upvotes: 0
Reputation: 362836
The Django request objects have a helper method available, called build_absolute_uri
:
request.build_absolute_uri()
Upvotes: 3