Skip to content Skip to sidebar Skip to footer

Django 1.9 Won't Render The Right Page In Links

demo/urls.py from django.conf.urls import url, include, patterns from django.contrib import admin import views from . import views urlpatterns = patterns('demo.urls', url(r'^

Solution 1:

You need to include a dollar sign at the end of your regex.

url(r'^$', views.login, name="login"),

Without the dollar sign, the regex r'^' will match all urls, so any url patterns below this one will be ignored.

You can actually remove this url and resetpwd from the root url config, because you already include these views in the included mechanics.urls.

Note that Django comes with an authentication system. You should use this rather than trying to write your own.

Solution 2:

There are several issues with your code:

First and foremost, you are completely working around Django's authentication system. If you know what you are doing this is fine (though it really makes you wonder why you are using Django, then).

In any other case, you should really be using it because:

  1. you are using plain text passwords (Django would not)
  2. you are not authenticating the user in Django thus you will not be able to use any of the features that come along with Django based on authentication, like the decorator login_required() which will handle correct redirecting to the login page, localization, permissions, password resetting via e-mail and many more.

As a side note:

You have two login and resetpw pages, and you include the admin site twice (in the base urls.py and in the mechanics one).

Post a Comment for "Django 1.9 Won't Render The Right Page In Links"