On Apr 21, 10:53 pm, Margie <margierogin...@yahoo.com> wrote:
> Can anyone advise me on what is the best way in the views.py code to
> return an HttpResponse that simply returns the user to the previous
> page they were on?
>
> For example, let's say that multiple different pages have a button
> that executes some code in views.py, but is not intended to actually
> take the user to a new page. So after executing that code, I just
> want to redisplay the previous page they were looking at.
It sounds like you don't want to leave the page while your code is
running
and then come back but just stay on the same page. A good option for
this would be AJAX using javascript. Another way would be to use the
same template. Users won't know what views function is run so more
than one can use the same template making it look like they are on the
same page.
> On a slightly more complicated note, say multiple different pages have
> a button that executes some code and then does redirect the user to
> page 'foo'. Now when the user clicks a 'submit' button on page
> 'foo', I would like to take them back to wherever they were before
> they got to page 'foo'.
>
It sounds like you want to have a link to a form that when the user
has
filled it out and submited you want to take them back to that page. I
would suggest that you send along to the view a variable containing
data where to send them back and use to redirect them to the right
place. I don't know if Django has an easier way to do it, but else
that
way is a pretty general way of doing it.
~Jakob
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---