Dec 15 2011

Django Site matching query does not exist.

Category: Uncategorizedtuxie @ 11:16

When you configure your brand new Django project you’ll see in your settings something like:


That ID refers to the Django “sites” framework. If you plan on using the admin interface make sure that ID exists in the database, otherwise you’ll get an error:

DoesNotExist at /admin/

Site matching query does not exist.

Request Method: GET
Request URL: http://localhost:8000/admin/
Django Version: 1.3
Exception Type: DoesNotExist
Exception Value:

Site matching query does not exist.

If it doesn’t exist, create it:

>>> from django.contrib.sites.models import Site
>>> site = Site()
>>> site.domain = ''
>>> = 'My website'

That’s the ID you should use in your settings file:


I disabled comments because I was sick of spam. If you want to comment on anything write me to alvaro@(this domain).