Fork of django-dynamicsites with the intent of removing modifications to django.contrib.sites.models
Python JavaScript
Failed to load latest commit information.
cms_example Examples README files Aug 26, 2014
example Examples README files Aug 26, 2014
.gitignore Added .gitignore Aug 26, 2014
README.rst add SITES_PACKAGE configuration value to match SITES_DIR for finding … Mar 29, 2012



Original dynamicsites By UYSRC <>

Host multiple sites from a single django project

Expands the standard django.contrib.sites package to allow for:

  • Sites identified dynamically from the request via middleware
  • No need for multiple virtual hosts at the webserver level
  • 301 Redirects to canonical hostnames
  • A site may have its own and templates
  • Allows for environment hostname mappings to use non-production hostnames (for use in dev, staging, test, etc. environments)


  1. Before you install dynamicsites, make sure you have configured at least 1 site in the admin panel, because once dynamicsites is installed, it will try to lookup a site from request.get_host(), and, if none exists, will always throw 404

  2. Add the app to INSTALLED_APPS

  3. Add the middleware to MIDDLEWARE_CLASSES

  4. Add the context processor to TEMPLATE_CONTEXT_PROCESSORS

  5. Configure dynamicsites by adding SITES_DIR, SITES_PACKAGE, DEFAULT_HOST, and HOSTNAME_REDIRECTS to

    SITES_DIR = os.path.join(os.path.dirname(__file__), 'sites')
    SITES_PACKAGE = 'sites'
    #    '':         '',
  6. If your local environment (eg. test, dev, staging) uses different hostnames than production, set the ENV_HOSTNAMES map as well

        '':    '',
  7. make sites dir (from the SITES_DIR setting above) and put a file inside

  8. make a site dir for each site you're hosting (eg. mkdir sites/www_mysitesdomain_com) <-- put underscores instead of dots in the domain name, these need to be imported as python packages. Make sure to put an file in each site dir as well.

  9. add a SITES_FILTER setting if you want to restrict the sites served by this project. SITES_FILTER is a dict used as follows when dynamicsiteslite looks up sites in the database:



In the current codebase, if you have the django debug toolba unstalled and enable redirect tracking, ie.


django-dynamicsites will intercept redirects, which is very helpful when dialing in your site config.

There's also a view included with the codebase which is useful for checking which site dynamicsites thinks you're seeing. Just add an entry to your file:

from dynamicsiteslite.views import site_info

urlpatterns += patterns('',
    url(r'^site-info$', site_info),)


  • in sites folder, each folder must have a file.

More Info

More info can be found here: