Opened 4 years ago

Closed 4 years ago

#18226 closed Cleanup/optimization (invalid)

tutorial documentation starting admin (part II)

Reported by: jerry@… 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


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, 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 Changed 4 years ago by aaugustin

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to needsinfo
  • Status changed from new to closed

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 ./ dumpdata sites --indent=2? Could you also confirm that your contains SITE_ID = 1? Thanks!

comment:2 Changed 4 years ago by anonymous contains SITE_ID = 1

# system time zone.
TIME_ZONE = 'Europe/Amsterdam'

# Language code for this installation. All choices can be found here:


# 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]$./ dumpdata sites --indent=2
./ dumpdata sites --indent=2

with # django.contrib.sites (disabled):

(django)[~/dev/jer_django]$./ dumpdata sites --indent=2
./ dumpdata sites --indent=2
Error: Unknown application: sites

Total stacktrace:


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

Django Version: 1.4
Python Version: 2.6.1
Installed Applications:
Installed Middleware:

File "/Users/jeroen/dev/jer_django/virtualenv/lib/python2.6/site-packages/django/core/handlers/" 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/" 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/" 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/" 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/" in inner
  195.                 return self.login(request)
File "/Users/jeroen/dev/jer_django/virtualenv/lib/python2.6/site-packages/django/views/decorators/" 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/" in login
  326.         return login(request, **defaults)
File "/Users/jeroen/dev/jer_django/virtualenv/lib/python2.6/site-packages/django/views/decorators/" in wrapper
  69.             return view(request, *args, **kwargs)
File "/Users/jeroen/dev/jer_django/virtualenv/lib/python2.6/site-packages/django/utils/" 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/" 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/" in login
  60.     current_site = get_current_site(request)
File "/Users/jeroen/dev/jer_django/virtualenv/lib/python2.6/site-packages/django/contrib/sites/" 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/" 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/" 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/" in get
  366.                     % self.model._meta.object_name)

Exception Type: DoesNotExist at /admin/
Exception Value: Site matching query does not exist.

comment:3 Changed 4 years ago by jerry@…

  • Resolution needsinfo deleted
  • Status changed from closed to reopened

comment:4 Changed 4 years ago by aaugustin

  • Resolution set to invalid
  • Status changed from reopened to closed

The traceback 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.

Version 0, edited 4 years ago by aaugustin (next)
Note: See TracTickets for help on using tickets.
Back to Top