10👍
The entry you saw originally on the admin/sites/site/
page, with example.com
and domain name
, is the one you should simply edit for the quickest results (instead of adding a new Site object).
What’s really happening?
In your settings file, Django automatically defines a SITE_ID
property when you create your project, which is by default set to 1
. This points to the example.com
Site you see in the admin. If you want to use the Site
object you created, or change Site objects later when you need the functionality, you can change that SITE_ID
property to the id of the Site
object you created. Hope this helps!
3👍
The site object in the template comes from the Django Site model. When you do a syncdb, it defaults automatically to example.com
If you login to Django’s admin interface, you will find “Sites”. Inside it, you will be able to change example.com
to whatever you like. Just set the id of the site u want to use as current site in your settings.py
as SITE_ID = ID
.
e.g if you editted the example.com
domain name to mysite.com
and display name as MYSITE
. then SITE_ID = 1
because that is the only content we have in our “Sites” table and its ID
is 1
. if like to add another “Sites” details leaving the example.com
untouched, remember to set the SITE_ID
to ID
of the one u added
- How to filter multiple fields with list of objects
- Perform a logical exclusive OR on a Django Q object
- How can I create a partial search filter in Django REST framework?