Opened 13 years ago
Closed 12 years ago
#18226 closed Cleanup/optimization (invalid)
tutorial documentation starting admin (part II)
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Documentation | Version: | 1.4 |
Severity: | Normal | Keywords: | BUG |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
When starting the admin site (Mac OS X 10.6.8, Python version 2.6.1) according to tutorial part2, I ran into an error:
DoesNotExist at /admin/ Site matching query does not exist
I found the solution at stackoverflow, http://stackoverflow.com/questions/6086852/how-to-fix-the-django-sites-table comment out the 'django.contrib.sites' in installed apps. Would be nice if the tutorial incorporates this message and solution.
Change History (4)
comment:1 by , 13 years ago
Resolution: | → needsinfo |
---|---|
Status: | new → closed |
comment:2 by , 13 years ago
settings.py contains SITE_ID = 1
# system time zone. TIME_ZONE = 'Europe/Amsterdam' # Language code for this installation. All choices can be found here: # http://www.i18nguy.com/unicode/language-identifiers.html LANGUAGE_CODE = 'en-us' SITE_ID = 1 # If you set this to False, Django will make some optimizations so as not # to load the internationalization machinery. USE_I18N = True
with django.contrib.sites enabled:
[](django)[~/dev/jer_django]$./manage.py dumpdata sites --indent=2 ./manage.py dumpdata sites --indent=2 [](django)[~/dev/jer_django]
with # django.contrib.sites (disabled):
(django)[~/dev/jer_django]$./manage.py dumpdata sites --indent=2 ./manage.py dumpdata sites --indent=2 Error: Unknown application: sites
Total stacktrace:
nvironment: Request Method: GET Request URL: http://localhost:8000/admin/ Django Version: 1.4 Python Version: 2.6.1 Installed Applications: ('django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.admin', 'south', 'debug_toolbar', 'poll') Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware') Traceback: File "/Users/jeroen/dev/jer_django/virtualenv/lib/python2.6/site-packages/django/core/handlers/base.py" in get_response 111. response = callback(request, *callback_args, **callback_kwargs) File "/Users/jeroen/dev/jer_django/virtualenv/lib/python2.6/site-packages/django/contrib/admin/sites.py" in wrapper 213. return self.admin_view(view, cacheable)(*args, **kwargs) File "/Users/jeroen/dev/jer_django/virtualenv/lib/python2.6/site-packages/django/utils/decorators.py" in _wrapped_view 91. response = view_func(request, *args, **kwargs) File "/Users/jeroen/dev/jer_django/virtualenv/lib/python2.6/site-packages/django/views/decorators/cache.py" in _wrapped_view_func 89. response = view_func(request, *args, **kwargs) File "/Users/jeroen/dev/jer_django/virtualenv/lib/python2.6/site-packages/django/contrib/admin/sites.py" in inner 195. return self.login(request) File "/Users/jeroen/dev/jer_django/virtualenv/lib/python2.6/site-packages/django/views/decorators/cache.py" in _wrapped_view_func 89. response = view_func(request, *args, **kwargs) File "/Users/jeroen/dev/jer_django/virtualenv/lib/python2.6/site-packages/django/contrib/admin/sites.py" in login 326. return login(request, **defaults) File "/Users/jeroen/dev/jer_django/virtualenv/lib/python2.6/site-packages/django/views/decorators/debug.py" in wrapper 69. return view(request, *args, **kwargs) File "/Users/jeroen/dev/jer_django/virtualenv/lib/python2.6/site-packages/django/utils/decorators.py" in _wrapped_view 91. response = view_func(request, *args, **kwargs) File "/Users/jeroen/dev/jer_django/virtualenv/lib/python2.6/site-packages/django/views/decorators/cache.py" in _wrapped_view_func 89. response = view_func(request, *args, **kwargs) File "/Users/jeroen/dev/jer_django/virtualenv/lib/python2.6/site-packages/django/contrib/auth/views.py" in login 60. current_site = get_current_site(request) File "/Users/jeroen/dev/jer_django/virtualenv/lib/python2.6/site-packages/django/contrib/sites/models.py" in get_current_site 92. current_site = Site.objects.get_current() File "/Users/jeroen/dev/jer_django/virtualenv/lib/python2.6/site-packages/django/contrib/sites/models.py" in get_current 25. current_site = self.get(pk=sid) File "/Users/jeroen/dev/jer_django/virtualenv/lib/python2.6/site-packages/django/db/models/manager.py" in get 131. return self.get_query_set().get(*args, **kwargs) File "/Users/jeroen/dev/jer_django/virtualenv/lib/python2.6/site-packages/django/db/models/query.py" in get 366. % self.model._meta.object_name) Exception Type: DoesNotExist at /admin/ Exception Value: Site matching query does not exist.
comment:3 by , 13 years ago
Resolution: | needsinfo |
---|---|
Status: | closed → reopened |
comment:4 by , 12 years ago
Resolution: | → invalid |
---|---|
Status: | reopened → closed |
The INSTALLED_APPS setting shows that you're using south; this means you haven't strictly followed the tutorial.
The default site is created by the post_syncdb signal. I suppose you haven't run syncdb when the tutorial told you, maybe because you've used migrate instead.
The solution you found on SO disables useful features of Django to work around the problem; it doesn't address the root cause. This is certainly not something we want to recommend in the tutorial.
I suppose that you Site object must not have id 1. To confirm this hypothesis, could you paste the output of
./manage.py dumpdata sites --indent=2
? Could you also confirm that yoursettings.py
containsSITE_ID = 1
? Thanks!