Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NameError:Admin not found in django

Tags:

django

The urls.py of the project is this

from django.conf.urls.defaults 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'^$', 'Sdr.views.home', name='home'),
    # url(r'^Sdr/', include('Sdr.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)),
    (r'', include('Sdr.sdr.urls')),
)

The urls.py of the app looks like this

# Import django modules
from django.conf.urls.defaults import *
from django.contrib import admin
# Import custom modules
import settings


admin.autodiscover()
urlpatterns = patterns('',
    url(r'^admin/', include(admin.site.urls)),
    (r'', include('Sdr.sdr.urls')),
)

The error I am getting is exception found is

Django Version: 1.3
Exception Type: NameError
Exception Value:    
name 'admin' is not defined
like image 474
Hick Avatar asked May 31 '11 09:05

Hick


2 Answers

You forgot to import admin in the project's urls.py. Read harder.

like image 114
Ignacio Vazquez-Abrams Avatar answered Oct 05 '22 03:10

Ignacio Vazquez-Abrams


Uncomment the following in your project's urls.py.

from django.contrib import admin

admin.autodiscover()
like image 30
Amazing Angelo Avatar answered Oct 05 '22 01:10

Amazing Angelo