[Answered ]-Cannot access django-admin panel on port

1👍

The error message "Site matching query does not exist," typically occurs in Django when the SITE_ID setting in settings.py refers to a Site object that does not exist in the database.

I managed to debug this with the Python Shell by checking existing site ID.

from django.contrib.sites.models import Site
existing_site = Site.objects.get(domain='http://127.0.0.1:8000')
print(existing_site.id)

The returning statement revealed that the SITE_ID should be 2, not 1 as previously set.

This was fixed with an update to settings.py to match the correct site ID:

SITE_ID = 2

The django admin panel can now be accessed without any further errors.

Leave a comment