Re: Site-wide User Authentication

2005-10-13 Thread Andreas
Maniac wrote: > You could subclass django.core.extensions.DjangoContext and > prefill it with your everpresent variables in __init__(). I ended up subclassing "Context". I was wrong when I said writing a custom Context doesn't seem to save code -- passing MyContext(request) to render_to_response

Re: Site-wide User Authentication

2005-10-05 Thread Andreas
Maniac wrote: > You could subclass django.core.extensions.DjangoContext and > prefill it with your everpresent variables in __init__(). I ended up writing a one-line custom middleware that makes the user-instance available to my views as request.user. In order to have the user-data not only in th

Re: Site-wide User Authentication

2005-10-05 Thread Maniac
Andreas wrote: mentioned that I don't, I'm using a custom model. Is there a way to make a custom model available in all views and templates without explicitly passing it as a parameter every time? You could subclass django.core.extensions.DjangoContext and prefill it with your everpresent v

Re: Site-wide User Authentication

2005-10-05 Thread Andreas
Jacob Kaplan-Moss wrote: > If you use django.core.extensions.DjangoContext instead of > django.core.template.Context the {{ user }} variable will > automatically be available in your templates. If > {{ user.is_anonymous }} is True then the user is *not* > logged in; otherwise the user info is ava

Re: Site-wide User Authentication

2005-10-04 Thread Adrian Holovaty
On 10/4/05, Jacob Kaplan-Moss <[EMAIL PROTECTED]> wrote: > On Oct 4, 2005, at 8:42 AM, Andreas wrote: > > What's the best way to check if a user is logged in on every page > > (read: view) of a website? I'd like to be able to display the username > > in the template if a user is logged in. At the

Re: Site-wide User Authentication

2005-10-04 Thread Jacob Kaplan-Moss
On Oct 4, 2005, at 8:42 AM, Andreas wrote: What's the best way to check if a user is logged in on every page (read: view) of a website? I'd like to be able to display the username in the template if a user is logged in. At the moment, I'm using the following code: If you use django.core.extens