views:

29

answers:

3

In django views,From the request how would we know from which page this view was called

 def password_change(request):
   if request.method == 'POST':
      u=request.user
      u.set_password(request.POST.get('new_password'))
      u.save()
      post_change_redirect= //Need old link here 
      return HttpResponseRedirect(post_change_redirect)
+1  A: 

try request.path

nbv4
Lets say the users access links /home from which change password, is called and on change of password this view is called ,so basically i want to be redirected to /home
Hulk
then additional parameter is needed. add something like callback=/home
nil
thanks it worked
Hulk
A: 
request.path

will return the full path (not including the domain).

e.g. /music/bands/the_beatles/

nil
+1  A: 

Normally a variable in the query string (accessible via request.GET) is used to instruct the view where to redirect to.

Ignacio Vazquez-Abrams