%define srcname django-hosts %define version 3.1.dev6+g316c340 %define release 5 Summary: Dynamic and static host resolving for Django. Maps hostnames to URLconfs. Name: python3-%{srcname} Version: %{version} Release: %{release} Source0: %{srcname}-%{version}.tar.gz License: BSD Group: Development/Libraries BuildArch: noarch Vendor: Jannis Leidel BuildRequires: python3-devel python3-setuptools_scm %description This Django app routes requests for specific hosts to different URL schemes defined in modules called "hostconfs". 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 a ``hosts.py`` file:: from django_hosts import patterns, host host_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 hostconfs. Patterns are evaluated in order. If no pattern matches, the request is processed in the usual way, ie. using the standard ``ROOT_URLCONF``. The patterns on the left-hand side are regular expressions. For example, the following ``ROOT_HOSTCONF`` setting will route ``foo.example.com`` and ``bar.example.com`` to the same URLconf. from django_hosts import patterns, host host_patterns = patterns('', host(r'(foo|bar)', 'path.to.urls', name='foo-or-bar'), ) note: Remember: * Patterns are matched against the extreme left of the requested host * It is implied that all patterns end either with a literal full stop (ie. ".") or an end of line metacharacter. * As with all regular expressions, various metacharacters need quoting. repository on Github: https://github.com/jazzband/django-hosts django-hosts.rtfd.org: https://django-hosts.readthedocs.io/ %{?python_provide:%python_provide python3-%{srcname}} %prep %autosetup -n %{srcname}-%{version} %build %py3_build %install %py3_install #%check #%{__python3} setup.py test %files -n %{name} #%license LICENSE %doc README.rst %{python3_sitelib}/*