Question

I've followed the Django tutorial part 1, and am now on part 2 where I'm supposed to get the admin interface up and running.

I've followed the step very carefully but when I try to load the site I get the following error:

Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order:
1. ^admin/
The current URL, , didn't match any of these.

I first uncommented 'django.contrib.admin' in settings.py:

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    # Uncomment the next line to enable the admin:
    'django.contrib.admin',
    # Uncomment the next line to enable admin documentation:
    # 'django.contrib.admindocs',
    'polls',
)

...after that I run python manage.py syncdb, which output:

Creating tables ...
Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)

...and then I uncommented the three lines that I was supposed to according to the tutorial, in urls.py:

from django.conf.urls import patterns, include, url

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    # Examples:
    # url(r'^$', 'mysite.views.home', name='home'),
    # url(r'^mysite/', include('mysite.foo.urls')),

    # Uncomment the admin/doc line below to enable admin documentation:
    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    url(r'^admin/', include(admin.site.urls)),
)

As mentioned above this generates an error message if run.

What can be wrong? I mean I've followed the tutorial exactly as supposed.

Was it helpful?

Solution

Notice the instruction in the tutorial:

Now, open a Web browser and go to “/admin/” on your local domain – e.g., http://127.0.0.1:8000/admin/.

Add the error shows, you are trying to go to the root URL, not /admin/ as directed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top