이슈 내용
admin페이지 접속시 이상한 페이지로 리다이렉션 되며 Site matching query does not exist 에러 발생
File "venv/lib/python3.9/site-packages/django/db/models/query.py", line 435, in get
raise self.model.DoesNotExist(
django.contrib.sites.models.Site.DoesNotExist: Site matching query does not exist.
[29/Nov/2022 11:51:20] "GET /admin/login/?next=/admin/ HTTP/1.1" 500 150660
해결 방법
admin에서 example.com 사이트를 삭제해서 난 오류였다.
방법 1-1
example.com 다시 추가해준다.
$> ./manage.py shell
>>> from django.contrib.sites.models import Site
>>> site = Site()
>>> site.domain = 'example.com'
>>> site.name = 'example.com'
>>> site.save()
1-2 root settings.py에 SITE_ID = 1 추가
# root settings.py에 추가
SITE_ID = 1
방법 2-1
$> ./manage.py shell
>>> from django.contrib.sites.models import Site
>>> site = Site.objects.create(domain='example.com', name='example.com')
>>> site.save()
2-2 root settings.py에 SITE_ID = 1 로 변경
# root settings.py에 추가
SITE_ID = 1
참고 자료
https://stackoverflow.com/questions/16068518/django-site-matching-query-does-not-exist
Django - Site matching query does not exist
Im trying to get the admin site of my app in Django working. Ive just sync`d the DB and then gone to the site but I get the error ... Site matching query does not exist. Any ideas ?
stackoverflow.com
'프레임워크 > Django' 카테고리의 다른 글
[allauth] allauth 비밀번호 변경후 리다이렉트 (0) | 2023.05.27 |
---|---|
[allauth] 프로필 이미지 문제 (0) | 2023.05.25 |
[allauth] 회원가입 로그인시 SMTPSenderRefused 오류 (0) | 2023.05.24 |
[Django] MVT 패턴 (0) | 2023.05.16 |
[Django] 장고 모델과 폼의 관계 (0) | 2023.05.08 |