Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

django - How to fix the django_sites table?

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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')

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...