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

后端 未结 12 2116
后悔当初
后悔当初 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:09

    The Site object for your Django project is missing. Each Django project has a Site object which contains the site's name and domain. It is usually automatically created when creating a Django project (in particular, when the syncdb command runs) but in your case it seems that didn't happen.

    To fix it:

    Open the Django shell for your site (python manage.py shell).

    Type the following:

    >>> from django.contrib.sites.models import Site
    >>> Site.objects.create(name='example.com', domain='example.com')
    

    If you want to change these values later, go to your admin panel (/admin/) and edit the site object in the section Sites.

提交回复
热议问题