django-hosts

Dynamic and static hosts support for Django
Download

django-hosts Ranking & Summary

Advertisement

  • Rating:
  • License:
  • BSD License
  • Publisher Name:
  • Jannis Leidel
  • Publisher web site:
  • http://github.com/jezdez/

django-hosts Tags


django-hosts Description

Dynamic and static hosts support for Django django-hosts is a Django middleware that routes requests to specific hosts to different URL schemes ("hostconf").For example, if you own example.com but want to serve specific content at api.example.com and beta.example.com, add the following to your hosts.py:from hosts import patterns, hosthost_patterns = patterns('path.to', host(r'api', 'api.urls', name='api'), host(r'beta', 'beta.urls', name='beta'),)This causes requests to {api,beta}.example.com to be routed to their corresponding URLconf. You can use your urls.py as a template for these URLconfs.Patterns are evaluated in order. If no pattern matches, the request is processed in the usual way, ie. using settings.ROOT_URLCONF.Installation Install the app with your favorite package manager, e.g.: pip install django-hosts Add 'hosts' to your INSTALLED_APPS setting. Add 'hosts.middleware.HostsMiddleware' to your MIDDLEWARE_CLASSES setting. Create a module containing your default host patterns, e.g. in the hosts.py file next to your urls.py. Set the ROOT_HOSTCONF setting to the dotted Python import path of the module containing your default host patterns, e.g.: ROOT_HOSTCONF = 'mysite.hosts' Set the DEFAULT_HOST setting to the name of the host pattern you want to refer to as the default pattern. It'll be used if no other pattern matches or you don't give a name to the host_url template tag (see below). Requirements: · Python What's New in This Release: · Fixed issue related to the PARENT_HOST setting when used with empty host patterns. · Stopped automatically emulating hosts in debug mode.


django-hosts Related Software