url for accounts/profile in Django

3.5k views Asked by At

I'm using Django 1.11 and new to it.

I'm using default login and logout functions.

When I login, it redirects to accounts/profile and then generates error as

Using the URLconf defined in myapp.urls, Django tried these URL patterns, in this order:

^ ^login/$ [name='login']
^ ^logout/$ [name='logout']
^ ^password_change/$ [name='password_change']
^ ^password_change/done/$ [name='password_change_done']
^ ^password_reset/$ [name='password_reset']
^ ^password_reset/done/$ [name='password_reset_done']
^ ^reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$ [name='password_reset_confirm']
^ ^reset/done/$ [name='password_reset_complete']
^ ^$ [name='home']
^pages/
^search/
^admin/

The current path, accounts/profile/, didn't match any of these.

Is accounts built-in function in Django?

If it is, how to access url to accounts app? If no, why it is there?

Edit 2 : url pattern from myapp.urls.py

urlpatterns = [
    url('^', include('django.contrib.auth.urls')),
    url('^', include('pages.urls')),
    url(r'^pages/', include('pages.urls')),
    url(r'^search/', include('search.urls')),
    url(r'^admin/', admin.site.urls),
]
2

There are 2 answers

2
Kos On BEST ANSWER

By default, successful login in Django redirects to:

  • URL passed as ?next= parameter in the URL, or
  • URL specified as settings.LOGIN_REDIRECT_URL otherwise.

Relevant code: LoginView.get_success_url()

0
aspo On

The url accounts, normally comes with the package django-registration. For my case, it is implemented as url(r'^accounts/', include('registration.backends.simple.urls')),. From there the redirect works. i.e. accounts/login, accounts/register etc. See the documentation