I have some problems with Django admin.
after syncdb, the result is:
Creating tables ...
Installing custom SQL ...
Installing indexes ...
No
You can fix this error if you are using django.contrib.sites
without removing it by changing SITE_ID = 1
value in settings.py
file.
It is happen to me when I changed domain name on my server, I deleted old domain name from http://mynewdomainname.com/admin/sites/site/
manually, and the old domain record in database has id = 1
, also I added new domain name mynewdomainname.com
and it is id was id = 2
,
I just changed to SITE_ID = 2
and the error gone SITE_ID refers to current "pk" of active domain name you use as default.
In code:
>>> from django.contrib.sites.models import Site
>>> # get_current() came from SiteManager class manager,
>>> # see site-packages/django/contrib/sites/models.py
>>> current_site = Site.objects.get_current()
>>> print(current_site.pk)
2
>>> print(current_site.domain)
'http://mynewdomainname.com'
this happen after settings.py
changed
SITE_ID = 2
Be careful about current domain id in django sites app.
just fixed the issue by an another way:
I use PostgreSQL and Django 1.45... as i removed the www.example.com Site and added a new www.xxx.com Site it was added as ID=2 'cause PostgreSQL doesn't go back in the ID numbers and the login and logout Django-Sites are somehow bound only to the ID=1 Site in your DB...
I went to my PostgreSQL DB and changed the ID of www.xxx.com to 1 and then I was able to see the login and logout Site again :)
btw. [yes, you just can remove the django.contrib.sites from your settings.py if you don't need it ^^ (but I haven't tried this one out in my case, with the ID number problem)]
hope it will work for further users! ;)
Check your Window task manager and make sure that there is 1 process name 'python.exe' is running. If there are many, delete all of them then restart the server. This solution works for me.