Search site_id site in Django Admin

I install Django AllAuth in my project and meet the following line in the documentation for this application (see docs here) :

Add a site for your domain that matches the parameters. SITE_ID (django.contrib.sites app).

My settings. SITE_ID 1, no wonder. How can I "combine" this with a Django admin? I have only 2 fields - domain name and display name.

And vice versa, if I create a site in admin, how do I know what site_id is?

+6
django
Jan 13 '14 at 5:59
source share
3 answers

You can find site_id in the address bar.

web browser screen shot showing Django administration and URL of interest

So the line in settings.py will be: SITE_ID = 3

+10
Jan 13 '14 at 6:10
source share

Follow the path to the project where you have the manage.py file and follow these steps:

Run the following command in terminal

  python manage.py shell 

Then in python shell type:

  from django.contrib.sites.models import Site new_site = Site.objects.create(domain='....', name='....') print new_site.id 

This printed value will be site_id for site compliance request. If you are still amazed, please respond. I will walk you through very simple and simple steps to enjoy the beauty of django allauth.

+3
Jan 13 '14 at
source share

This works for me:

user$ python manage.py shell --settings you-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$ 

Hope this helps. (◠ïđâ— )

0
03 Oct '17 at 1:19 on
source share



All Articles