1
    Environment:


Request Method: GET
Request URL: http://54.235.168.5/mds/

Django Version: 1.3.1
Python Version: 2.7.3
Installed Applications:
['sana.mrs',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'sana.mrs.util.LoggingMiddleware')


Traceback:
File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
  101.                             request.path_info)
File "/usr/lib/python2.7/dist-packages/django/core/urlresolvers.py" in resolve
  250.             for pattern in self.url_patterns:
File "/usr/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/lib/python2.7/dist-packages/django/core/urlresolvers.py" in _get_urlconf_module
  274.             self._urlconf_module = import_module(self.urlconf_name)
File "/usr/lib/python2.7/dist-packages/django/utils/importlib.py" in import_module
  35.     __import__(name)
File "/opt/sana/urls.py" in <module>
  131.     (r'^admin/(.*)', admin.site.root),

Exception Type: AttributeError at /
Exception Value: 'AdminSite' object has no attribute 'root'

可能的重复项是How to correct this error: "'Adminsite' object has no attribute 'root'"

提到您的管理员网址应该是:

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

不是(r'^admin/(.*)', admin.site.root) - 它适用于 Django 1.0。对于 Django 1.3,它不起作用。

然后我得到了这个错误

NameError at / name 'include' 未定义

    Environment:

Request Method: GET
Request URL: http://54.235.168.5/mds/

Django Version: 1.3.1
Python Version: 2.7.3
Installed Applications:
['sana.mrs',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'sana.mrs.util.LoggingMiddleware')


Traceback:
File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
  101.                             request.path_info)
File "/usr/lib/python2.7/dist-packages/django/core/urlresolvers.py" in resolve
  250.             for pattern in self.url_patterns:
File "/usr/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/lib/python2.7/dist-packages/django/core/urlresolvers.py" in _get_urlconf_module
  274.             self._urlconf_module = import_module(self.urlconf_name)
File "/usr/lib/python2.7/dist-packages/django/utils/importlib.py" in import_module
  35.     __import__(name)
File "/opt/sana/urls.py" in <module>
  132.  url(r'^admin/', include(admin.site.urls))

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

我正在使用 Django 版本 1.3.1。

4

3 回答 3

2

你有这个吗

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

在你的urls.py

于 2013-01-28T17:34:46.823 回答
1

它接缝你忘记了from django.conf.urls.defaults import *from django.conf.urls.defaults import include在你的 urls.py 中。

于 2013-01-28T17:34:22.813 回答
1

你可能还没有导入它:

from django.conf.urls.defaults import include

一般来说,当它说 somethingis not defined时,意味着编译器无法解析某些东西。这通常是由于缺少导入语句或拼写错误造成的。

于 2013-01-28T17:34:30.193 回答