How to Use the Django Sites Framework

/*--- holy mAcar00ns!! --- */

Instructions from the Django Book are skimpy.

How to Use the Sites Framework

The sites framework is more a series of conventions than a framework. The whole thing is based on two simple concepts:

The Site model, found in django.contrib.sites, has domain and name fields.

The SITE_ID setting specifies the database ID of the Site object associated with that particular settings file.

How you use these two concepts is up to you, but Django uses them in a couple of ways automatically via simple conventions.

To install the sites application, follow these steps:

Add 'django.contrib.sites' to your INSTALLED_APPS.
Run the command syncdb to install the django_site table into your database. This will also create a default site object, with the domain

Change the site to your own domain, and add any other Site objects, either through the Django admin site or via the Python API. Create a Site object for each site/domain that this Django project powers.

Define the SITE_ID setting in each of your settings files. This value should be the database ID of the Site object for the site powered by that settings file.

Here's another clue.

And perhaps a better way to do this.

The official documentation.

The closest thign toa tutorial:

Next you’ll want to create separate settings files for each domain you’re adding; each one will need its own MEDIA_URL and other settings. You’ll also want to do two things to make sure everything works out properly for administering the different sites:

Create a new Site object in your admin for each domain, and put the id of that Site into its settings file as SITE_ID so Django knows which site in the database corresponds to this settings file.

In the settings file for your original site (the one with id 1), add the other sites’ settings files to the ADMIN_FOR setting, to let Django know that this one instance of the admin application will handle all of the sites.

Now you can use the single Django admin running on your domain to create weblogs which will show up on your friends’ domains.

A couple more leads:

deploying with django's sites framework on webfaction

Serving Multiple Hosts from a Single Django Instance

Labels: ,

all your bases ar--

ping moi pleeez

About this entry

pacman is coming

nuck nuck

e belong to us!