I have some problems with Django admin.
after syncdb, the result is:
Creating tables ...
Installing custom SQL ...
Installing indexes ...
No
Since the above comments are pretty old and the syncdb
command doesn't exist, and I don't want to remove django.contrib.sites
, here's what worked for me:
Increment SITE_ID
. I had SITE_ID = 1
, changed it to SITE_ID = 2
and everything worked again.
Yes change the SITE_IT=1 to SITE_ID=2 and everything is ok
The same problem also suddenly came to me, and you know there're many solutions. However, what's the reason of this sudden problem?
After dig in deeply, I found the reason is that, we ignored a step in the first syncdb action.
When you have your first syncdb, django will ask you to create a default account, if you don't input in this interactive show, that site object would not be created automatically.
So be careful of this. I'm using django 1.3.1, don't know whether the latest version has resolved this issue.
Yes, the solution mentioned at the top can be (part of) the solution.
I've noticed however, that not only including django.contrib.sites
without configuration can cause that problem, also including any site of
allauth
(pip install django-allauth) might cause this problem if said package is not configured correctly.
(And allauth
is as far as I've seen not configured correctly by default...)
Add SITE_ID = 1
in your settings.py
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='www.example.com', name='example.com')