I would like to have a part of my webpage reserved for login
information (a login form, and if a user has logged in succesfully,
some information & options).
Now, the login form is in the base.html template. base.html checks
whether user info is known (by looking at session variables), if there
is none, an empty loginform is shown.
The login form POSTs its data to an url that points to a view. This
view (receiving the request) checks with the database whether the
login/password combination is a valid one, and sets the session
variables if so. It then HttpResponseRedirects back to the referring
page (because the login form is available all over the site,
The problem is: how can I pass context info through this? Suppose I'd
want to maintain the login information the user has entered in the
form, and reprint it in the form, together with an error message? Is
there a way to HttpResponseRedirect and pass context variables in the
mean time?
I tried working with custom template tags for this, but then I would
have to pass the context variables from the view to the template and
then to the template tag. This seems too convoluted to me. Also, it
seems difficult to pass the request information to the template tag..
Thanks in advance,
Mathieu
You can pass the required data through the GET variables, like
redirecting to:
http://example.com/someurl?var=value
Hope that helps a bit,
Michael
def Main(request, context, template):
# Main does what it has to do with the request information (login info,
search strings, session vars...)
return render_to_response(context, template)
(This is from the top of my head, I don't remember the exact variables
render_to_response demands).
I feel I have more control over what each view does, and it
standardises the whole application a lot more as well.