Retrieving arguments from HTTP_REFERER string
Question: I am currently building a Python/Django application where I have a search
function and is looking great.

`http://localhost:8000/search/?q=&start=Feb+13%2C+Sat&end=Feb+20%2C+Sat`

Then say I selected a link from the number of listed results the led me to the
detail of the product whiche is another page. On the Django view of the
product detail I captured the HTTP_REFERER using:

    
    
    referer_url = request.META.get('HTTP_REFERER')
    

`referer_url` is now a string.

I wanted to retrieve the data included in the `referer_url` like:

    
    
    start = self.request.GET.get("start") 
    print start
    

Desired output is:

`Feb 13, Sat`

however I seem to have difficulty. Any ideas?


Answer: You can use the [`parse_qs`
method](https://docs.python.org/2/library/urlparse.html#urlparse.parse_qs) of
`urlparse` module:

    
    
    import urlparse
    
    parsed = urlparse.parse_qs(referer_url)
    print parsed['start'][0]
    

the result would be:

    
    
    Feb 13, Sat
    

