To create a separate decorator, then all other view functions are decorated
by this decorator. For implement this decorator, you don't need to include
the login function, just redirect to login URL. Is that what you are asking
for?

On Sat, Feb 5, 2011 at 6:48 PM, Marc Aymerich <glicer...@gmail.com> wrote:

> On Sat, Feb 5, 2011 at 9:21 AM, Ken Chida <ken.ch...@gmail.com> wrote:
> > I tried my best to search for an answer but my efforts yielded nothing.
> > Allow me to give you a simple example to illustrate my problem.  Let's
> > pretend that I want to have a login form on every single page on my
> > website.  Obviously, the login form will have a corresponding view
> > function.  What is the most elegant way to implement the login
> functionality
> > on every single page?  One brute force method would be to include the
> login
> > view inside all view functions for every page; these view functions would
> > call the login view if the HttpRequest object contains a flag that
> becomes
> > active when the user clicks the login submit button.  This method would
> > work, but it goes against DRY best practices.
> >
> > Is there a better way to do this?  Maybe I can use a custom template tag?
>
> it sounds to me like you need a custom decorator for your views, I
> can't give you more details since I've never written one.
>
> --
> Marc
>
> --
> 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<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
===========================
Regards
Ronghui Yu

-- 
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.

Reply via email to