如何纠正此错误:“管理站点”对象没有属性“root”

发布于 2024-10-28 21:58:03 字数 5076 浏览 1 评论 0原文

完整的错误消息是:

在 apache 上作为 localhost 运行 Django 应用程序时出现 AttributeError --“Adminsite”对象没有属性“root”

Environment:
Request Method: GET
Request URL: http://localhost:8000/

Django Version: 1.3
Python Version: 2.6.5
Installed Applications:
['django.contrib.auth', 'django.contrib.contenttypes',
 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.admin',
 'esp.datatree', 'esp.users', 'esp.membership', 'esp.miniblog',
 'esp.web', 'esp.program', 'esp.program.modules', 'esp.dbmail',
 'esp.cal', 'esp.lib', 'esp.setup', 'esp.qsd', 'esp.qsdmedia',
 'esp.resources', 'esp.gen_media', 'esp.dblog', 'esp.membership',
 'esp.queue', 'esp.survey', 'esp.accounting_core', 'esp.accounting_docs',
 'esp.shortterm', 'esp.utils', 'esp.cache', 'esp.cache_loader', 'esp.tagdict',
 'django_extensions', 'south', 'sslauth']
Installed Middleware:
['esp.middleware.threadlocalrequest.ThreadLocals',
 'esp.middleware.FixIEMiddleware',
 'esp.middleware.ESPErrorMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'esp.middleware.espauthmiddleware.ESPAuthMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.middleware.doc.XViewMiddleware',
 'sslauth.middleware.SSLAuthMiddleware',
 'django.middleware.gzip.GZipMiddleware',
 'esp.middleware.PrettyErrorEmailMiddleware',
 'esp.middleware.StripWhitespaceMiddleware',
 'django.middleware.transaction.TransactionMiddleware',
 'esp.datatree.middleware.DataTreeLockMiddleware']

Traceback:
File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/core/handlers/base.py" in get_response
  101.                             request.path_info)
File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/core/urlresolvers.py" in resolve
  250.             for pattern in self.url_patterns:
File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/core/urlresolvers.py" in _get_url_patterns
  279.         patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/core/urlresolvers.py" in _get_urlconf_module
  274.             self._urlconf_module = import_module(self.urlconf_name)
File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/utils/importlib.py" in import_module
  35.     __import__(name)
File "/home/lakshay/mysite/esp/esp/esp/../esp/urls.py" in 
  58.                      (r'^admin/(.*)', admin.site.root),

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

编辑以响应 Aldarund< /a>:

是的,我确实更正了管理员的 URL,但现在它给出了数据库错误。可能是什么问题?这是回溯:

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

Traceback:
File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/core/handlers/base.py" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "/home/lakshay/mysite/esp/esp/esp/../esp/web/views/main.py" in home
  79.     nav_category, created = NavBarCategory.objects.get_or_create(name='home')
File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/db/models/manager.py" in get_or_create
  135.         return self.get_query_set().get_or_create(**kwargs)
File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/db/models/query.py" in get_or_create
  378.             return self.get(**lookup), False
File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/db/models/query.py" in get
  344.         num = len(clone)
File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/db/models/query.py" in __len__
  82.                 self._result_cache = list(self.iterator())
File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/db/models/query.py" in iterator
  273.         for row in compiler.results_iter():
File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/db/models/sql/compiler.py" in results_iter
  680.         for rows in self.execute_sql(MULTI):
File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/db/models/sql/compiler.py" in execute_sql
  735.         cursor.execute(sql, params)
File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/db/backends/util.py" in execute
  34.             return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/db/backends/postgresql_psycopg2/base.py" in execute
  44.             return self.cursor.execute(query, args)

Exception Type: DatabaseError at /
Exception Value: relation "web_navbarcategory" does not exist
LINE 1: ...me", "web_navbarcategory"."long_explanation" FROM "web_navba...
                                                             ^

The full error message is:

AttributeError on running Django app on apache as localhost -- 'Adminsite' object has no attribute 'root'

Environment:
Request Method: GET
Request URL: http://localhost:8000/

Django Version: 1.3
Python Version: 2.6.5
Installed Applications:
['django.contrib.auth', 'django.contrib.contenttypes',
 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.admin',
 'esp.datatree', 'esp.users', 'esp.membership', 'esp.miniblog',
 'esp.web', 'esp.program', 'esp.program.modules', 'esp.dbmail',
 'esp.cal', 'esp.lib', 'esp.setup', 'esp.qsd', 'esp.qsdmedia',
 'esp.resources', 'esp.gen_media', 'esp.dblog', 'esp.membership',
 'esp.queue', 'esp.survey', 'esp.accounting_core', 'esp.accounting_docs',
 'esp.shortterm', 'esp.utils', 'esp.cache', 'esp.cache_loader', 'esp.tagdict',
 'django_extensions', 'south', 'sslauth']
Installed Middleware:
['esp.middleware.threadlocalrequest.ThreadLocals',
 'esp.middleware.FixIEMiddleware',
 'esp.middleware.ESPErrorMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'esp.middleware.espauthmiddleware.ESPAuthMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.middleware.doc.XViewMiddleware',
 'sslauth.middleware.SSLAuthMiddleware',
 'django.middleware.gzip.GZipMiddleware',
 'esp.middleware.PrettyErrorEmailMiddleware',
 'esp.middleware.StripWhitespaceMiddleware',
 'django.middleware.transaction.TransactionMiddleware',
 'esp.datatree.middleware.DataTreeLockMiddleware']

Traceback:
File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/core/handlers/base.py" in get_response
  101.                             request.path_info)
File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/core/urlresolvers.py" in resolve
  250.             for pattern in self.url_patterns:
File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/core/urlresolvers.py" in _get_url_patterns
  279.         patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/core/urlresolvers.py" in _get_urlconf_module
  274.             self._urlconf_module = import_module(self.urlconf_name)
File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/utils/importlib.py" in import_module
  35.     __import__(name)
File "/home/lakshay/mysite/esp/esp/esp/../esp/urls.py" in 
  58.                      (r'^admin/(.*)', admin.site.root),

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

Edit in response to Aldarund:

Yes, I did correct the URL for admin, but now it is giving a database error. What could be the problem? Here is the traceback:

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

Traceback:
File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/core/handlers/base.py" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "/home/lakshay/mysite/esp/esp/esp/../esp/web/views/main.py" in home
  79.     nav_category, created = NavBarCategory.objects.get_or_create(name='home')
File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/db/models/manager.py" in get_or_create
  135.         return self.get_query_set().get_or_create(**kwargs)
File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/db/models/query.py" in get_or_create
  378.             return self.get(**lookup), False
File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/db/models/query.py" in get
  344.         num = len(clone)
File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/db/models/query.py" in __len__
  82.                 self._result_cache = list(self.iterator())
File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/db/models/query.py" in iterator
  273.         for row in compiler.results_iter():
File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/db/models/sql/compiler.py" in results_iter
  680.         for rows in self.execute_sql(MULTI):
File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/db/models/sql/compiler.py" in execute_sql
  735.         cursor.execute(sql, params)
File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/db/backends/util.py" in execute
  34.             return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/db/backends/postgresql_psycopg2/base.py" in execute
  44.             return self.cursor.execute(query, args)

Exception Type: DatabaseError at /
Exception Value: relation "web_navbarcategory" does not exist
LINE 1: ...me", "web_navbarcategory"."long_explanation" FROM "web_navba...
                                                             ^

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

人生百味 2024-11-04 21:58:03

您的管理员网址应该是:
url(r'^admin/', include(admin.site.urls))
不是 (r'^admin/(.*)', admin.site.root)
- 适用于 Django 1.0。对于 Django 1.3 来说它不起作用。

Your url for admin should be:
url(r'^admin/', include(admin.site.urls))
not (r'^admin/(.*)', admin.site.root)
- it's for Django 1.0. For Django 1.3 it wouldn't work.

握住你手 2024-11-04 21:58:03

我遇到的另一个可能的问题是,admin 尚未在 settings.py 文件中正确配置。遇到此问题的任何人都需要检查他们安装的应用程序是否包含 django.contrib.admin。参考 https://docs.djangoproject.com/en/1.3/faq/admin/< /a> 了解详细信息。

Another possible issue here, which I encountered, is that admin has not been properly configured in the settings.py file. Anyone having this issue would want to check that their installed apps include django.contrib.admin. Reference https://docs.djangoproject.com/en/1.3/faq/admin/ for details.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文