Finding the site_id of a Site in Django Admin

后端 未结 3 1444
花落未央
花落未央 2020-12-16 04:45

I\'m installing Django AllAuth into my project and have come across the following line in the documentation for that app (see docs here):

Add a Site f

3条回答
  •  温柔的废话
    2020-12-16 05:00

    This works for me:

    user$ python manage.py shell --settings your-settings.py

    [ ... banner ... ]
    >>>
    >>> from django.contrib.sites.models import Site
    >>>
    >>> sorted([(site.id,site.name) for site in Site.objects.all()])
    [(1, u'www.lvh.me'), (2, u'example.com'), (3, u'www.example.com'),...]
    >>>
    >>> quit()
    user$
    

提交回复
热议问题