On Feb 5, 3:21 am, Ken Chida <[email protected]> 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?
>
> Thanks in advance!!
> Ken
You can include everything you need in a template context processor
(e.g., login form).
This will make it available in every template, so you can do like
{{ login_form.as_p }} in the base template.
And the form just points to /login/ to process the login information.
Look for template context processors in the docs. They might be
exactly when you need.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.