Simple multihost handling for Django
Django-Multihost is a Django middleware that overrides Site ORM functionality and gets the current Site from the Host header. The code is loosely based on the work done by Bruce Kroeze here: django-threaded-multihost.
The MultiHostMiddleware class contained in this app has 2 tasks:
Copy or symlink the multihost package into your django project directory or install it by running one of the following commands:
python setup.py install
pip install django-multihost
Add MULTIHOST_REDIRECT_URL to settings.py
Add multihost.middleware.MultiHostMiddleware to your MIDDLEWARE_CLASSES in at the end of the list. If you find it isn’t working, move it up the list order as there may be a middleware conflict.
Note: Django does strange things (like sending requests to the wrong urls handler) when it is used in conjunction with debug_toolbar. To fix this problem, multihost must always be the last entry in MIDDLEWARE_CLASSES.
There are 2 settings that developers can use to override default functionality:
It is important to note that the MultiHostMiddleware middleware does database lookups against the Django tables corresponding to the
Site model - in particular, against the
domain field. In the default Django implementation (version 1.2.1 as of writing), the
domain field is not indexed or unique and this may result in slower performance over time.
For this reason, web site/application developers should weigh the benefits and consider manually adding an index for the
domain field using standard database access tools.
The latest source code can always be found here: github.com/jaddison/django-multihost
Django-Multihost is maintained by James Addison.
Django-Multihost is Copyright (c) 2010-2012, James Addison. It is free software, and may be redistributed under the terms specified in the LICENSE file.
Feel free to open an issue here: github.com/jaddison/django-multihost/issues
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|File Name & Checksum SHA256 Checksum Help||Version||File Type||Upload Date|
|django-multihost-0.3.macosx-10.8-intel.exe (71.8 kB) Copy SHA256 Checksum SHA256||any||Windows Installer||Dec 7, 2012|
|django-multihost-0.3.tar.gz (5.5 kB) Copy SHA256 Checksum SHA256||–||Source||Dec 7, 2012|