سؤال

I use "django-registration" by James Bennett. To hook up it to my project I have to write in my main url file:

(r'^users/', include('registration.urls')),

So then all urls of this app will be start with "users/". It isn't bad. But for "login" I want to use just home directory "/".

How to do this without changing the "django-registration" source files? I tried to use "redirect_to" in my main url file:

    url('users/login/$',
    'django.views.generic.simple.redirect_to',
    {'url': 'login/'}),

But it just adds "login/" to the end of "users/login/" and I get "user/login/login/.

هل كانت مفيدة؟

المحلول

Probably you should just add

(r'^login/', 'registration.views.name_of_login_view'),

to your project main urls.py.

Regarding your URL try using {'url': '/login/'} instead of {'url': 'login/'}

نصائح أخرى

{'url': '/login/'}),

Change 'login/' to '/login' to fix. Path starts with '/' means 'I will be added from home path, not current'.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top