tags:

views:

25

answers:

1

In Django if a request is made to another module. Can we know where the request has made from through the request variable...

In the below example I have to know that the request was made from a.html ort that corresponding module

Ex: a.html

<html>
<form onsubmit=/b>

</form>
</html>
+1  A: 

In your view code you can do something like this:

def my_view(request)
  referer = request.META.get('HTTP_REFERER', '')
  if referer == 'absolute/path/to/somepage.html':
    # do something
    ...
  else:
    # do something else
    ...

Note that you probably want to avoid hard-coding URLs in your view code (as I've done above for the sake of simplicity, you probably want to use reverse().

Dominic Rodger
Thanks................................
Hulk