Skip to content

Commit

Permalink
Add Django 2.0; drop older Djangos that are or soon will be out of su…
Browse files Browse the repository at this point in the history
…pport
  • Loading branch information
dpoirier committed Mar 26, 2018
1 parent a85f5a6 commit 226b59e
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 23 deletions.
4 changes: 2 additions & 2 deletions runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
'mptt',
'treenav',
),
MIDDLEWARE_CLASSES=(
MIDDLEWARE=(
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
Expand Down Expand Up @@ -52,7 +52,7 @@
],
# Load models directly to pick up test-only models
# See: http://stackoverflow.com/a/25267435/347942
MIGRATION_MODULES={'treenav': 'treenav.migrations_not_run_during_tests'},
MIGRATION_MODULES={'treenav': None},
SECRET_KEY='this-is-just-for-tests-so-not-that-secret',
ROOT_URLCONF='treenav.tests.urls',
)
Expand Down
2 changes: 1 addition & 1 deletion sample_project/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
django>=1.8,<1.9
django>=2.0,<2.1
django-mptt>=0.8.6,<1.0
20 changes: 9 additions & 11 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
[tox]
envlist = {py27,py34,py35}-{dj1.8,dj1.9,dj1.10},py33-dj1.8,flake8,coverage,docs
envlist = {py27,py34,py36}-dj1.11,{py34,py36}-dj2.0,flake8,coverage,docs

[testenv]
basepython =
py27: python2.7
py33: python3.3
py34: python3.4
py35: python3.5
py36: python3.6
deps =
dj1.8: Django>=1.8,<1.9
dj1.9: Django>=1.9,<1.10
dj1.10: Django>=1.10,<1.11
dj1.11: Django>=1.11,<2.0
dj2.0: Django>=2.0,<2.1
commands = {envpython} runtests.py

[testenv:flake8]
basepython = python3.5
basepython = python3.6
commands = flake8 .
deps = flake8>=2.2.2

[testenv:coverage]
passenv = TRAVIS TRAVIS_JOB_ID TRAVIS_BRANCH
basepython = python3.5
basepython = python3.6
commands =
coverage run runtests.py
coverage report -m --fail-under 85
deps =
Django>=1.8,<1.9
Django>=2.0,<2.1
coverage>=3.7.1

[testenv:docs]
basepython = python2.7
deps = Sphinx==1.2.2
basepython = python3.6
deps = Sphinx
commands = {envbindir}/sphinx-build -a -n -b html -d docs/_build/doctrees docs docs/_build/html
2 changes: 1 addition & 1 deletion treenav/admin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from functools import update_wrapper
from django.conf.urls import url
from django.contrib import admin
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.contrib.contenttypes.admin import GenericStackedInline
from django.shortcuts import redirect
from django.utils.translation import ugettext_lazy as _
Expand Down
2 changes: 1 addition & 1 deletion treenav/forms.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django import forms
from django.core.urlresolvers import reverse, NoReverseMatch
from django.urls import reverse, NoReverseMatch
from django.core.exceptions import ObjectDoesNotExist
from django.core.validators import URLValidator

Expand Down
6 changes: 4 additions & 2 deletions treenav/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes import fields
from django.core.cache import cache
from django.core.urlresolvers import reverse
from django.urls import reverse

from mptt.managers import TreeManager
from mptt.models import MPTTModel, TreeForeignKey
Expand Down Expand Up @@ -88,7 +88,8 @@ def update(self, *args, **kwargs):

class MenuItem(MPTTModel):

parent = TreeForeignKey('self', null=True, blank=True, related_name='children')
parent = TreeForeignKey('self', null=True, blank=True, related_name='children',
on_delete=models.CASCADE)
label = models.CharField(
_('label'),
max_length=255,
Expand All @@ -115,6 +116,7 @@ class MenuItem(MPTTModel):
ContentType,
null=True,
blank=True,
on_delete=models.CASCADE,
)
object_id = models.CharField(
# use a CharField to be able to point to tables with UUID pks
Expand Down
2 changes: 1 addition & 1 deletion treenav/tests/test_views.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.core.cache import cache
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.http import HttpRequest
from django.template.context import Context
from django.template import Template
Expand Down
9 changes: 5 additions & 4 deletions treenav/tests/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from django.contrib import admin

import treenav.urls
from ..admin import MenuItemAdmin
from ..models import MenuItem

Expand All @@ -25,16 +26,16 @@ def test_view(request, item_slug):
return HttpResponse(t.render(c))


def test_404(request):
def test_404(request, exception=None):
return HttpResponseNotFound()


handler404 = test_404 # noqa


urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'^admin2/', include(site2.urls)),
url('^admin/', admin.site.urls),
url('^admin2/', site2.urls),
url(r'^item/(?P<item_slug>[\w-]+)/$', test_view, name='test_view'),
url(r'^old/', include('treenav.urls')),
url(r'^old/', include(treenav.urls)),
]

0 comments on commit 226b59e

Please sign in to comment.