Saturday, February 5, 2011

Re: Best DRY practices for a view function that will be used by all other views.

You don't need a "dedicated" login page with a form like the default login for django admin. All you need is a urlpattern (i.e. domain.com/login) that would allow for forms in other pages to POST to it. You would obviously need a view to handle that POST, but you don't need to link to it anywhere in your website. You just need to be able to work with the POST information.


Best regards,
André Terra

On Sat, Feb 5, 2011 at 22:58, Ken Chida <ken.chida@gmail.com> wrote:
Hi James - I want to point out that I will not have a dedicated login URL, as the functionality will be available on each page (not just a link to the login page, but the actual form).  Previously, I had a dedicated login URL and link to the login page, but my frontend guy made a slick jQuery drop-down login/register box that shows up on each page.  As to whether this was a good way to implement login is a whole different story that goes beyond the scope of what I'm dealing with at the moment. 

I'm kinda leaning towards a decorator for each view function.  At least the login view code will be in one place.  The only thing I will be repeating over and over is "@login", which isn't a big deal.

Base.html already has the necessary html/JS to show the login form.  I just need to figure out how to organize or call the view code.

Let's suppose that we're on my blog page.  The login/register form from base.html shows at the top of the page and the blog is directly below it.  If the user enters login info and clicks the login submit button, what mechanism should I use to ensure that the request object goes to the login view code -- wherever it might live (not implying that it has to be in a view.py).

Thanks!

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment