开发者

Django-Admin.py not working

开发者 https://www.devze.com 2023-04-06 18:07 出处:网络
I\'m a complete noob at django and i cant seem to get the admin page up and running. I\'ve set the urls.py correctly, and i\'ve enabled the app in the settings.py module...all the database settings ar

I'm a complete noob at django and i cant seem to get the admin page up and running. I've set the urls.py correctly, and i've enabled the app in the settings.py module...all the database settings are correctly defined. Help please The error thrown is as shown below

Environment:


Request Method: GET
Request URL: http://127.0.0.1:8000/admin

Django Version: 1.3
Python Version: 2.7.1
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
' jango.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')


    Traceback:
    File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in          get_response
  89.                     response = middleware_method(request)
     File "/usr/local/lib/python2.7/dist-packages/django/middleware/common.py" in process_request
  67.             if (not _is_valid_path(request.path_info, urlconf) and
File "/usr/local/lib/python2.7/dist-packages/django/middleware/common.py" in _is_valid_path
  154.         urlresolvers.resolve(path, urlconf)
     File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in resolve
  342.     return get_resolver(urlconf).resolve(path)
   File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in resolve
  250.             for pattern in self.url_patterns:
    File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in _get_url_patterns
  279.         patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
    File "/usr/loc开发者_开发问答al/lib/python2.7/dist-packages/django/core/urlresolvers.py" in _get_urlconf_module
  274.             self._urlconf_module = import_module(self.urlconf_name)
    File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py" in  import_module
  35.     __import__(name)
    File "/home/mjanja/workspace/DjangoProjectsLinux/ModelsDemo/../ModelsDemo/urls.py" in <module>
  16.      url(r'^admin/', include(admin.site.urls)),

    Exception Type: NameError at /admin
    Exception Value: name 'admin' is not defined


you are most probably missing the following lines @ the beginning of urls.py:

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


seems like you may have forgotten to uncomment a few lines in the default urls.py in the project root.

check the urls.py in the project root, it should at least have the following:

from django.conf.urls.defaults import patterns, include, url
from django.contrib import admin
admin.autodiscover()

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

Also, i see a missing "d" for "django" in your settings.py above for the line:

' jango.contrib.sessions.middleware.SessionMiddleware'


This is pretty old, but I noticed that in the list of installed middleware, one line is missing the 'd' in 'django'

Installed Middleware:
('django.middleware.common.CommonMiddleware',
' jango.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
0

精彩评论

暂无评论...
验证码 换一张
取 消