Kenneth Gonsalves wrote:
I did create my own login decorator for this site for my own views  that
are using it.  But to use my decorator for the password views would
mean duplicating (or copying) all that code.

use user_passes_test - it allows you to specify the url you want.

Yes, that's what I'm doing in my own login decorator. The problem is that if I want to take advantage of django.contrib.auth.views' change_password method, which already has a decorator, I'm stuck.

I'm not at work and can't easily test this, but I wonder if this would work...

  # urls.py
  r('/account/password_change/', \
    'mywebsite.profile.views.password_change', \
    {'template_name': 'account/pwchange.html'}),

  # mywebsite.profile.views.py
  password_change = \
    login_required(django.contrib.auth.views.password_change)

... where login_required is my own custom decorator that uses "user_passes_test" and redirects to /login/ instead of /accounts/login/.

I'd have to look at the code, but I think the problem would be the password_change method is already decorated, and this would decorate it twice.

-Rob

(This should probably on django-users at this point, my apologies for perpetuating it here...)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django 
developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to