[Django]-Why does <myproject>/accounts/profile/ show the <myproject>/profile/ page

2👍

✅

Your profile url path is not being limited to match only the start of the url:

    url('profile/', include('user_profile.urls')),

This will match anything like gibberishprofile/ for example, including accounts/profile/. If you change the url config to

    url('^profile/', include('user_profile.urls')),  # note the ^ before profile

Then only profile/ will match.

5👍

Actually redirecting to /accounts/profile/ is default behavior in django. In django global settings, it is defined as LOGIN_REDIRECT_URL. Django expects you to implement this page/url. Django django-allauth also uses same setting to redirect user after login.

If you want to redirect to any other page like /profile/, override this setting in your project settings.

LOGIN_REDIRECT_URL = '/profile/'

Or if you want django-allauth not to redirect at all set LOGIN_REDIRECT_URL = False in your settings as described here.

Leave a comment