From 4eddd86129c8150183db93f90ff241aa8a988b7f Mon Sep 17 00:00:00 2001 From: ma0 Date: Thu, 16 Mar 2017 14:30:16 -0500 Subject: [PATCH 1/5] added support for django 1.10 --- subdomains/middleware.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/subdomains/middleware.py b/subdomains/middleware.py index a88d6f2..2190586 100644 --- a/subdomains/middleware.py +++ b/subdomains/middleware.py @@ -11,7 +11,12 @@ logger = logging.getLogger(__name__) lower = operator.methodcaller('lower') -UNSET = object() +try: + from django.utils.deprecation import MiddlewareMixin +except ImportError: + MiddlewareMixin = object + +UNSET = MiddlewareMixin() class SubdomainMiddleware(object): From 7ae8473b4073df0b8fcae04fd1fc91e6ed6aa929 Mon Sep 17 00:00:00 2001 From: ma0 Date: Thu, 16 Mar 2017 14:38:47 -0500 Subject: [PATCH 2/5] modified index.rst, added 'django.contrib.sites' to installed apps --- .gitignore | 1 + docs/index.rst | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index b8281fc..8040284 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ build/ dist/ pip-log.txt +.idea/ diff --git a/docs/index.rst b/docs/index.rst index 897463e..6854d8b 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -34,9 +34,10 @@ To set up subdomain URL routing and reversing in a Django project: :class:`django.middleware.common.CommonMiddleware`, the subdomain middleware should come before :class:`~django.middleware.common.CommonMiddleware`. 2. Configure your ``SUBDOMAIN_URLCONFS`` dictionary in your Django settings file. -3. Ensure that you've set up your ``SITE_ID`` in your Django settings file, - and that the ``Site.domain`` attribute for that site corresponds to the - domain name where users will be accessing your site at. +3. Ensure that `django.contrib.sites` is in your INSTALLED_APPS, you've set up your + ``SITE_ID`` in your Django settings file, and that the ``Site.domain`` attribute + for that site corresponds to the domain name where users will be accessing your + site at. 4. If you want to use the subdomain-based ``{% url %}`` template tag, add ``subdomains`` to your ``INSTALLED_APPS``. From 7114ad5dca134f80c59003fee41067998d68625c Mon Sep 17 00:00:00 2001 From: ma0 Date: Thu, 16 Mar 2017 14:48:32 -0500 Subject: [PATCH 3/5] added django 1.10 to travis --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 614a144..cd52c64 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,7 @@ env: - DJANGO='Django==1.7.*' - DJANGO='Django==1.8.*' - DJANGO='Django==1.9.*' + - DJANGO='Django==1.10.*' matrix: exclude: # Django >= 1.7 does not support Python 2.6 From 63d625a0fe22d88d22cee0baae233311b83e0718 Mon Sep 17 00:00:00 2001 From: ma0 Date: Thu, 16 Mar 2017 16:10:27 -0500 Subject: [PATCH 4/5] added test compatibility to test in django 1.10 --- .travis.yml | 2 ++ setup.py | 3 ++- subdomains/tests/__init__.py | 5 +++++ subdomains/tests/urls/api.py | 17 +++++++++++++++-- subdomains/tests/urls/application.py | 17 +++++++++++++++-- subdomains/tests/urls/default.py | 17 +++++++++++++++-- subdomains/tests/urls/marketing.py | 17 +++++++++++++++-- 7 files changed, 69 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index cd52c64..6d7ccff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,6 +21,8 @@ matrix: env: DJANGO='Django==1.8.*' - python: "2.6" env: DJANGO='Django==1.9.*' + - python: "2.6" + env: DJANGO='Django==1.10.*' # Django < 1.7 does not support Python 3.4 - python: "3.4" env: DJANGO='Django==1.4.*' diff --git a/setup.py b/setup.py index 096e09a..dc836f7 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,8 @@ def get_version(): install_requires = ['django'] tests_require = install_requires + ['mock'] -setup(name='django-subdomains', +setup( + name='django-subdomains', version=version, url='http://github.com/tkaemming/django-subdomains/', author='ted kaemming', diff --git a/subdomains/tests/__init__.py b/subdomains/tests/__init__.py index d4f41e2..fea0df9 100644 --- a/subdomains/tests/__init__.py +++ b/subdomains/tests/__init__.py @@ -17,6 +17,11 @@ 'django.middleware.common.CommonMiddleware', 'subdomains.middleware.SubdomainURLRoutingMiddleware', ), + TEMPLATES=[ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + } + ] ) diff --git a/subdomains/tests/urls/api.py b/subdomains/tests/urls/api.py index 6a87900..89de97f 100644 --- a/subdomains/tests/urls/api.py +++ b/subdomains/tests/urls/api.py @@ -1,7 +1,20 @@ try: - from django.conf.urls import patterns, url + from django.conf.urls import url except ImportError: - from django.conf.urls.defaults import patterns, url # noqa + from django.conf.urls.defaults import url # noqa + +try: + from django.conf.urls import patterns +except ImportError: + try: + from django.conf.urls.defaults import patterns # noqa + except ImportError: + def patterns(*args): + new_patterns = [] + for a in args: + if a: + new_patterns.append(a) + return new_patterns from subdomains.tests.urls.default import urlpatterns as default_patterns from subdomains.tests.views import view diff --git a/subdomains/tests/urls/application.py b/subdomains/tests/urls/application.py index 5e91463..1931f51 100644 --- a/subdomains/tests/urls/application.py +++ b/subdomains/tests/urls/application.py @@ -1,7 +1,20 @@ try: - from django.conf.urls import patterns, url + from django.conf.urls import url except ImportError: - from django.conf.urls.defaults import patterns, url # noqa + from django.conf.urls.defaults import url # noqa + +try: + from django.conf.urls import patterns +except ImportError: + try: + from django.conf.urls.defaults import patterns # noqa + except ImportError: + def patterns(*args): + new_patterns = [] + for a in args: + if a: + new_patterns.append(a) + return new_patterns from subdomains.tests.urls.default import urlpatterns as default_patterns from subdomains.tests.views import view diff --git a/subdomains/tests/urls/default.py b/subdomains/tests/urls/default.py index 6473707..2b27adb 100644 --- a/subdomains/tests/urls/default.py +++ b/subdomains/tests/urls/default.py @@ -1,7 +1,20 @@ try: - from django.conf.urls import patterns, url + from django.conf.urls import url except ImportError: - from django.conf.urls.defaults import patterns, url # noqa + from django.conf.urls.defaults import url # noqa + +try: + from django.conf.urls import patterns +except ImportError: + try: + from django.conf.urls.defaults import patterns # noqa + except ImportError: + def patterns(*args): + new_patterns = [] + for a in args: + if a: + new_patterns.append(a) + return new_patterns from subdomains.tests.views import view diff --git a/subdomains/tests/urls/marketing.py b/subdomains/tests/urls/marketing.py index b28562b..36cdd03 100644 --- a/subdomains/tests/urls/marketing.py +++ b/subdomains/tests/urls/marketing.py @@ -1,7 +1,20 @@ try: - from django.conf.urls import patterns, url + from django.conf.urls import url except ImportError: - from django.conf.urls.defaults import patterns, url # noqa + from django.conf.urls.defaults import url # noqa + +try: + from django.conf.urls import patterns +except ImportError: + try: + from django.conf.urls.defaults import patterns # noqa + except ImportError: + def patterns(*args): + new_patterns = [] + for a in args: + if a: + new_patterns.append(a) + return new_patterns from subdomains.tests.urls.default import urlpatterns as default_patterns From ebefc414fe8bfcafec7e33cecf8e30061c9f5ac2 Mon Sep 17 00:00:00 2001 From: ma0 Date: Thu, 16 Mar 2017 16:16:52 -0500 Subject: [PATCH 5/5] modified readme.rst with integration with travis ci --- README.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index 0ed24a4..ada34f4 100644 --- a/README.rst +++ b/README.rst @@ -9,8 +9,8 @@ Full documentation can be found here: http://django-subdomains.readthedocs.org/ Build Status ------------ -.. image:: https://secure.travis-ci.org/tkaemming/django-subdomains.png?branch=master - :target: http://travis-ci.org/tkaemming/django-subdomains +.. image:: https://secure.travis-ci.org/contraslash/django-subdomains.png?branch=master + :target: http://travis-ci.org/contraslash/django-subdomains Tested on Python 2.6, 2.7, 3.4 and 3.5 on their supported Django versions from -1.4 through 1.9. +1.4 through 1.10.