0

So i just want my sitemap.xml to work in production.

I have included this module in INSTALLED_APPS:

'django.contrib.sites',

I have declared SITE_ID:

SITE_ID = 1

I defined domain name 'mydomain.com' in sites model which is exacly the domain my site running on.

I restarted the server

And i still get 'django.contrib.sites.models.Site.DoesNotExist: Site matching query does not exist' error

I don't get this error when i run on localhost.

Labtoxs
  • 73
  • 1
  • 4
  • Does this answer your question? [Django - Site matching query does not exist](https://stackoverflow.com/questions/16068518/django-site-matching-query-does-not-exist) – PacketLoss Apr 21 '21 at 23:21
  • No. Everything is defined. django.contrib.sites in INSTALLED_APPS, SITE_ID=1, and a site row with the domain my site is running on. – Labtoxs Apr 21 '21 at 23:25

1 Answers1

1

So the problem was that i deleted the "example.com" instance instead of modifying it and created a new one. To solve the problem delete your instance again and create a new one with id=1. Site.objects.create(id=1, name='example.com', domain='example.com')

Labtoxs
  • 73
  • 1
  • 4
  • You can also run `python manage.py migrate sites zero` to undo the sites migration, followed by `python manage.py migrate sites` to re-do it. – DragonBobZ Aug 16 '23 at 17:44