How to redirect all the views in django-allauth to homepage/index instead of /accounts/* -


i using django-allauth user authentication in django project.

my question is: how change default urls django-allauth of them point websites index/home page?

i able display the login , registration form on index , seem work fine. want is, on index page instead of being on /accounts/something.

so example, when invalid login details entered, redirects /accounts/login, want redirect homepage , display error messages there itself. same goes email confirmation, signup etc.

using redirectview.as_view in urls.py allauth doesn't seem pass data in request.

here project's urls.py

from django.conf.urls import patterns, include, url django.contrib import admin  urlpatterns = patterns('',     # examples:     # url(r'^$', 'instapayback.views.home', name='home'),     # url(r'^blog/', include('blog.urls')),      url(r'^admin/', include(admin.site.urls)),     url(r'^', include('main_site.urls')),     url(r'^accounts/', include('allauth.urls')),     # url(r'', include('social_auth.urls')), ) 

i still new django, kindly requested descriptive possible.

this how got did it. not (yet) tested, seems job.

1) remove url(r'^accounts/', include('allauth.urls'))

from urlpatterns (since overriding it).

2) copy url-pattern skeleton allauth

go \site-packages\allauth\account\urls.py , copy urls need. may want copy urls \site-packages\allauth\socialaccount\urls.py, if using social media signups (facebook etc.)

paste patterns main urls.py. urls.py should this:

from allauth.account import views allauth_views  urlpatterns = [     ....      url(r"^signup/$", allauth_views.signup, name="account_signup"),     url(r"^login/$", allauth_views.login, name="account_login"),     url(r"^logout/$", allauth_views.logout, name="account_logout"),      url(r"^password/change/$", allauth_views.password_change,         name="account_change_password"),     url(r"^password/set/$", allauth_views.password_set, name="account_set_password"),      url(r"^inactive/$", allauth_views.account_inactive, name="account_inactive"),      # e-mail     url(r"^email/$", allauth_views.email, name="account_email"),     url(r"^confirm-email/$", allauth_views.email_verification_sent,         name="account_email_verification_sent"),     url(r"^confirm-email/(?p<key>[-:\w]+)/$", allauth_views.confirm_email,         name="account_confirm_email"),      # password reset     url(r"^password/reset/$", allauth_views.password_reset,         name="account_reset_password"),     url(r"^password/reset/done/$", allauth_views.password_reset_done,         name="account_reset_password_done"),     url(r"^password/reset/key/(?p<uidb36>[0-9a-za-z]+)-(?p<key>.+)/$",         allauth_views.password_reset_from_key,         name="account_reset_password_from_key"),     url(r"^password/reset/key/done/$", allauth_views.password_reset_from_key_done,         name="account_reset_password_from_key_done"),      .... ] 

3) use "name"s of urls in templates

for example: 'login' link use

<a href="{% url 'account_login' %}">login</a> 

i found this article helpful (how override view external django app).


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -