1
votes

Running Python 2.5 Django 1.2.4

Error message while testing basic setup. First time I enter the /admin URL in my browser, I get error message:

In template c:\dd\ddproject\src\templates\admin\base_site.html, error at line 10

Caught NoReverseMatch while rendering: Reverse for 'django.contrib.auth.views.logout' with arguments '()' and keyword arguments '{}' not found.

Exception Location: C:\Python25\lib\site-packages\django\template\defaulttags.py in render, line 385

Here's the code at line 10

<a href="{% url django.contrib.auth.views.logout %}">{% trans 'Log out' %}</a> 

I'm reluctant to include my entire settings.py file. But to answer your next questions, here's the relevant settings:

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
 )

 ROOT_URLCONF = 'src.urls'

 TEMPLATE_DIRS = (
     "/dd/ddproject/src/templates",
 )

 INSTALLED_APPS = (
     'django.contrib.auth',
     'django.contrib.contenttypes',
     'django.contrib.sessions',
     'django.contrib.sites',
     'django.contrib.messages',
     'django.contrib.admin',
     'django.contrib.admindocs',
 )
4

4 Answers

2
votes

If you're including settings.py in your question without being prompted, you can't be that much of a newbie :-)

If you're not defining your own login/logout urls, just remember to include the auth urls in your urls.py file. Best to do this last:

from django.conf.urls.defaults import *

urlpatterns = patterns('',
    # ... other URL defs and includes here ....
    (r'', include('django.contrib.auth.urls')),
)
0
votes

You need to add in urls.py:

#Session management
(r'^login/$','django.contrib.auth.views.login'),

Or maybe you are using

(r'^admin$',include(admin.site.urls)),
(r'^admin/$',include(admin.site.urls)),

instead of :

(r'^admin',include(admin.site.urls)),
0
votes

I added this line to my urls.py and problem solved: url('', include('django.contrib.auth.urls')), I am using Django 1.5

-1
votes

What fixed this for me, was to use absolute paths in INSTALLED_APPS in settings.py. So:

'myproject.myapp',

and not

'myapp',