18

I've installed all apps in a project, then added a site in the sites section, and deleted example.com. Now Pages section in Django CMS 2.0 isn't working: it raises a DoesNotExist exception: Site matching query does not exist. at http://127.0.0.1:8000/admin/cms/page/

The section worked normally before I deleted the example.com site.

In settings.py I have SITE_ID = 2 line. Still, in this call:

return Site.objects.get(pk=site_pk) 

in traceback, site_pk=1.

How can I fix this?

culebrón
  • 34,265
  • 20
  • 72
  • 110
  • 4
    I was having this problem after receiving an error during `syncdb`. It never occurred to me that if the syncdb is interrupted, the default site is never created. To fix this I just added a site object manually via `django-admin.py shell` – Timmy O'Mahony Feb 15 '12 at 18:13

2 Answers2

17

From http://docs.djangoproject.com/en/dev/ref/contrib/sites/#ref-contrib-sites

The SITE_ID setting specifies the database ID of the Site object associated with that particular settings file.

So, check the django_site table and make sure you are using the correct SITE_ID for your site.

dr-jan
  • 2,124
  • 2
  • 21
  • 22
0

after adding sites framework, first you need python manage.py migrate then you only need to add SITE_ID=1 in settings.py.

Salman
  • 106
  • 1
  • 4