Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added compatibility with Django 1.10 #64

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
build/
dist/
pip-log.txt
.idea/
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -20,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.*'
Expand Down
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
7 changes: 4 additions & 3 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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``.

Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
7 changes: 6 additions & 1 deletion subdomains/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
5 changes: 5 additions & 0 deletions subdomains/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
'django.middleware.common.CommonMiddleware',
'subdomains.middleware.SubdomainURLRoutingMiddleware',
),
TEMPLATES=[
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
}
]
)


Expand Down
17 changes: 15 additions & 2 deletions subdomains/tests/urls/api.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
17 changes: 15 additions & 2 deletions subdomains/tests/urls/application.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
17 changes: 15 additions & 2 deletions subdomains/tests/urls/default.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
17 changes: 15 additions & 2 deletions subdomains/tests/urls/marketing.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down