Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix the django_sites table?

Tags:

Trying to get an oauth module to work I made the pro-move of : manage.py reset sites

This had the effect killing the admin and login functionality of my site.

So, my question is how to I get back to square one and fix what I broke.

Here is my current error when trying to display the admin tool:

DoesNotExist at /admin/ Site matching query does not exist. Request Method: GET Request URL:    http://mdev.5buckchuck.com/admin/ Django Version: 1.3 Exception Type: DoesNotExist Exception Value:     Site matching query does not exist.` 

I looked at the documentation but I am lost and tired in it: http://docs.djangoproject.com/en/1.3/ref/contrib/sites/

It seemed to indicate: manage.py syncdb

So, I wonder what to do next...

like image 478
bmartinek Avatar asked May 22 '11 08:05

bmartinek


2 Answers

You don't really need the sites framework if you only run one site from the project, so the easiest fix would be to remove the following item from your INSTALLED_APPS and the error should go away:

'django.contrib.sites' 

You can also re-create the missing Site object from shell. Run python manage.py shell and then:

from django.contrib.sites.models import Site Site.objects.create(pk=1, domain='mdev.5buckchuck.com', name='5buckchuck.com') 
like image 77
Jakub Roztocil Avatar answered Oct 12 '22 20:10

Jakub Roztocil


Provide SITE_ID=1 in settings.py. This will work.

like image 20
vikas0713 Avatar answered Oct 12 '22 21:10

vikas0713