Django - Site matching query does not exist

后端 未结 4 1818
盖世英雄少女心
盖世英雄少女心 2020-12-14 09:21

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 doe         


        
相关标签:
4条回答
  • 2020-12-14 09:26

    You also need to make sure that the site domain is the same with the one you actually use. For example if you are you are accessing the admin site from http://127.0.0.1:8000/admin/ then your site.domain should be: site.domain = '127.0.0.1:8000'.

    0 讨论(0)
  • 2020-12-14 09:34

    Adding SITE_ID=1 on settings.py did the trick for me.

    0 讨论(0)
  • 2020-12-14 09:36

    Add django.contrib.sites in django INSTALLED_APPS and also add SITE_ID=1 in your django setting file.

    0 讨论(0)
  • 2020-12-14 09:37

    Every django app needs a Site to run. Here you do not seem to have it.

    Log into your django shell

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

    or

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

    You should be all set.

    0 讨论(0)
提交回复
热议问题