0

I am writing a Django application. In my 'urls.py' I have written a URL pattern like this:

url(r'^rest/post/(.*)/$', rest_post),

Now when I am passing some URL like:

http://www.google.com/a?b

In my rest_post view I am getting only: http://www.google.com/a

I want to get the full URL. How do I do it?

anirban.at.web
  • 349
  • 2
  • 11
  • Most people would consider your `a` and your `b` very different things (path and search string, respectively). URL matching is normally done on URLs up to but not including the search string. – Amadan Dec 21 '15 at 04:03
  • @Amadan Actually I am building a URL shortener. So I need to pass the URL to my views in order to process it. Is there any way I can do that? – anirban.at.web Dec 21 '15 at 04:06
  • 1
    See the linked question on how to get the original request path; or you can see [other methods of `request`](https://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpRequest.get_full_path) for fetching any other request datum. – Amadan Dec 21 '15 at 04:08

1 Answers1

1

simply

request.get_full_path() 

in your views.

see https://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpRequest.get_full_path

doniyor
  • 36,596
  • 57
  • 175
  • 260