Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Site matching query does not exist

Tags:

python

django

Python noob, as in this is my first project, so excuse my unfamiliarity.

The site was working very well until I clicked "log out" on my app. After that, the website would give me this error: DoesNotExist at /login/ Site matching query does not exist.

I searched everywhere and the only solution I get relates to setting up the site framework, SITE_ID, etc. I think those items on my computer are fine, but I can't find a walkthrough/guide to help me check on them.

Can anyone tell me what the problem is and how to fix it? Thanks in advance :3

 DATABASES = {     'default': {         'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.         'NAME': '/home/dotcloud/nhs.db',                      # Or path to database file if using sqlite3.         'USER': '',                      # Not used with sqlite3.         'PASSWORD': '',                  # Not used with sqlite3.         'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.         'PORT': '',                      # Set to empty string for default. Not used with sqlite3.     } } 
like image 778
user1576866 Avatar asked Aug 05 '12 04:08

user1576866


2 Answers

If you don't have a site defined in your database and django wants to reference it, you will need to create one.

From a python manage.py shell :

from django.contrib.sites.models import Site new_site = Site.objects.create(domain='foo.com', name='foo.com') print (new_site.id) 

Now set that site ID in your settings.py to SITE_ID

like image 60
jdi Avatar answered Sep 22 '22 03:09

jdi


Table django_site must contain a row with the same value than id (by default equals to 1), as SITE_ID is set to (inside your settings.py).

like image 27
michael_arshynov Avatar answered Sep 23 '22 03:09

michael_arshynov