django-dynamicsites-liteHost multiple sites from a single Django project | |
Download |
django-dynamicsites-lite Ranking & Summary
Advertisement
- License:
- Other/Proprietary Li...
- Price:
- FREE
- Publisher Name:
- Ian Ward
- Publisher web site:
- http://excess.org/templayer/
django-dynamicsites-lite Tags
django-dynamicsites-lite Description
django-dynamicsites-lite is a Django app that 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 urls.py and templates- Allows for environment hostname mappings to use non-production hostnames (for use in dev, staging, test, etc. environments)Configuration 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 4041. Add the app to INSTALLED_APPS INSTALLED_APPS = ( ... 'dynamicsiteslite', )2. Add the middleware to MIDDLEWARE_CLASSES MIDDLEWARE_CLASSES = ( ... 'dynamicsiteslite.middleware.DynamicSitesMiddleware' )3. Add the context processor to TEMPLATE_CONTEXT_PROCESSORS TEMPLATE_CONTEXT_PROCESSORS = ( ... 'dynamicsiteslite.context_processors.current_site', )4. Configure dynamicsites by adding SITES_DIR, SITES_PACKAGE, DEFAULT_HOST, and HOSTNAME_REDIRECTS to settings.py SITES_DIR = os.path.join(os.path.dirname(__file__), 'sites') SITES_PACKAGE = 'sites' DEFAULT_HOST = 'www.your-default-site.com' HOSTNAME_REDIRECTS = { # 'redirect-src-1.com': 'www.redirect-dest-1.com', ... }5. If your local environment (eg. test, dev, staging) uses different hostnames than production, set the ENV_HOSTNAMES map as well ENV_HOSTNAMES = { 'my-site.dev': 'www.your-default-site.com', ... }6. make sites dir (from the SITES_DIR setting above) and put a __init__.py file inside7. make a site dir for each site you're hosting (eg. mkdir sites/www_mysitesdomain_com) Product's homepage
django-dynamicsites-lite Related Software