Search code examples
djangodjango-urlsdjango-registration

django_registration urls and routing confusion


I am new to Django and so I am learning how it works, I got a pretty decent web app stood up and I was playing around with the django_registration plugin. The thing that confused me is that the templates live in the root site /registration and I can access them from URLs like this:

<a href="{% url 'registration_register' %}">

So I thought I could do that for everything in registration but it was not so, as this doesn't work:

<a href="{% url 'registration_login' %}">

Confused what it is about one that works, and not the other (I sort of come from a rails background and I could see the routes there) this one I am having trouble learning, this was after going through why some urls in my app use a mysite:polls etc with the semi colon (that I think I get) just confused on the ones that don't live under an app namespace so to speak.

Or should registration_login of worked and I really just did something wrong on the template setup or the urls.py or something? Just trying to get some background.


Solution

  • Edit: Just saw it was the login url that was giving you the problem. I'll leave the other section about registration_register up for future reference in case it happens to be useful.

    The url for the login is located here and is named auth_login

    registration_register bit:

    Did you set INCLUDE_REGISTER_URL to False in your settings.py file?

    Check the source for the urls located here and you'll see the following snippet

    if getattr(settings, 'INCLUDE_REGISTER_URL', True): #Defaults to True
        urlpatterns += [
            url(r'^register/$',
                RegistrationView.as_view(),
                name='registration_register'),
        ]