Wednesday 15 June 2011

request - How does Django know who the user is? -


According to Django, there is a "user" attribute in the HttpRequest object that represents the currently logged in user if the Django installation is active authentication. What is the user requesting object? Does the middleware set the user in a cookie and save that cookie in the client browser, when the user logs in? In my code, I save the user ID (auth_user table) after logging in to a session variable and I usually check it on every page. If this information is always available in the request item, then I do not have to do this. All I need to do is check request.user.id. Is it true?

Thank you.

Yes, you've got it, except that the user data is stored in the session. You are working redundant by keeping track of yourself - this is great on some Django! Check out .. more


No comments:

Post a Comment