django - Cómo corregir este error: "El objeto ''Adminsite'' no tiene atributo ''root''"
apache ubuntu-10.04 (2)
El mensaje de error completo es:
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''
Edite en respuesta a Aldarund :
Sí, he corregido la URL de administrador, pero ahora está dando un error de base de datos. ¿Cual podría ser el problema? Aquí está el rastreo:
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... ^
Otro posible problema aquí, que encontré, es que el administrador no se ha configurado correctamente en el archivo settings.py. Cualquiera que tenga este problema querría comprobar que sus aplicaciones instaladas incluyen django.contrib.admin. Referencia https://docs.djangoproject.com/en/1.3/faq/admin/ para más detalles.
Su url para el administrador debe ser:
url(r''^admin/'', include(admin.site.urls))
no (r''^admin/(.*)'', admin.site.root)
- es para Django 1.0. Para Django 1.3 no funcionaría.