English 中文(简体)
Django-Admin.py 不工作
原标题:Django-Admin.py not working

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/local/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
最佳回答

你们最可能没有以下线:ur开始。 py:

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

似乎像你可能忘记,在项目根基的缺省中,有几行不通。

核对项目根基中的<代码>urls.py,至少应当有:

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)),
)

而且,我看到你环境中的“django”失踪。 页: 1

  jango.contrib.sessions.middleware.SessionMiddleware 

这相当陈旧,但我注意到,在安装的中层设备清单中,一条线缺失了 d干。

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




相关问题
How to get two random records with Django

How do I get two distinct random records using Django? I ve seen questions about how to get one but I need to get two random records and they must differ.

Moving (very old) Zope/Plone Site to Django

I am ask to move data from a (now offline) site driven by Plone to a new Django site. These are the version informations I have: Zope Version (unreleased version, python 2.1.3 ) Python Version 2.1....

Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

Flexible pagination in Django

I d like to implement pagination such that I can allow the user to choose the number of records per page such as 10, 25, 50 etc. How should I go about this? Is there an app I can add onto my project ...

is it convenient to urlencode all next parameters? - django

While writing code, it is pretty common to request a page with an appended "next" query string argument. For instance, in the following template code next points back to the page the user is on: &...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

热门标签