Re: Best DRY practices for a view function that will be used by all other views.
Your last paragraph here indicates to me you don't under HTML forms. I
think you need to go read about them and you'll understand why people
keep telling you don't need to do anything funny with decorating your
views or whatever just because your form is now on every page.
In short, your form needs to POST to some URL (I.e. /login or
something like that). You can post to that URL from any page. Just
make sure your URL patterns maps the URL the form is posting to your
login view code and it'll work like you want.
Good luck,
Pete
On Feb 5, 7:58 pm, Ken Chida <ken.ch...@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.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home