开发者

How to correct this error: "'Adminsite' object has no attribute 'root'"

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, ar开发者_运维百科gs)

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


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.


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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜