Site matching query does not exist

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


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


Add SITE_ID = 1 to settings.py in your django project.

Tags:

Python

Django