xpetta
xpetta

Reputation: 718

I'm unable to access Django Admin site

I'm unable to login to the Django Admin site. Below are the excerpts from the error for your kind reference:

Environment:


Request Method: GET
Request URL: http://127.0.0.1:8000/admin/login/?next=/admin/

Django Version: 3.0.3
Python Version: 3.8.0
Installed Applications:
[.
 .
 .
'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.sites',
 .
 .
 .
]

Exception Type: DoesNotExist at /admin/login/
Exception Value: Site matching query does not exist.

I did try the steps listed below:

$> python manage.py shell
>>> from django.contrib.sites.models import Site
>>> site = Site()
>>> site.domain = 'example.com'
>>> site.name = 'example.com'
>>> site.save()

It didn't help, got the following error:

.
.
sqlite3.IntegrityError: UNIQUE constraint failed: django_site.domain
.
.
django.db.utils.IntegrityError: UNIQUE constraint failed: django_site.domain
.
.

I would be really thankful if anyone could please help me in fixing this issue.

Upvotes: 0

Views: 136

Answers (1)

xpetta
xpetta

Reputation: 718

Adding SITE_ID = 1 within the settings.py resolved the issue.

Upvotes: 1

Related Questions