Getting Site Matching Query Does Not Exist Error after creating django admin

后端 未结 12 2127
后悔当初
后悔当初 2020-12-07 15:05

I\'m going through the standard Django tutorial to create an admin for an app. After commenting the admin related stuff in settings and running syncdb I\'m getting this mess

12条回答
  •  悲哀的现实
    2020-12-07 15:11

    Site object is missed so you have to add 1 Site object

    Solution:

    open Django shell(python manage.py shell):

    In [1]: from django.contrib.sites.models import Site
    
    In [2]: Site.objects.create(name='example.com',domain='example.com').save()
    
    In [3]: s=Site.objects.filter(name='example.com')[0]
    
    In [4]: s.id
    Out[4]: 3
    

    then open your settings.py file and add SITE_ID = 3 put that value in SITE_ID = which you get after (s.id)

提交回复
热议问题