Skip to content
This repository has been archived by the owner on Jan 15, 2022. It is now read-only.

Commit

Permalink
Fix imports for Django >=3.0
Browse files Browse the repository at this point in the history
Fixes #60
  • Loading branch information
prymitive committed Feb 19, 2020
1 parent 14e7b91 commit 68de971
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 19 deletions.
18 changes: 15 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,27 @@ python:

env:
matrix:
- DJANGO=2.0.7
- DJANGO=3.0.3
- DJANGO=2.2.10
- DJANGO=2.0.13
- DJANGO=1.8.19
- DJANGO=1.10.8
- DJANGO=1.11.14
- DJANGO=1.11.28

matrix:
exclude:
- python: "2.7"
env: DJANGO=2.0.7
env: DJANGO=2.0.13
- python: "2.7"
env: DJANGO=2.2.10
- python: "2.7"
env: DJANGO=3.0.3
- python: "3.4"
env: DJANGO=2.2.10
- python: "3.4"
env: DJANGO=3.0.3
- python: "3.5"
env: DJANGO=3.0.3
- python: "3.6"
env: DJANGO=1.8.19
- python: "3.6"
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM debian:jessie
FROM debian:stable

LABEL maintainer "Łukasz Mierzwa <[email protected]>"

RUN apt-get update && apt-get install --no-install-recommends -y python3-dev python3-pip libyaml-dev git \
RUN apt-get update && apt-get install --no-install-recommends -y python3-dev python3-pip python3-setuptools libyaml-dev git \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@
from django.utils.html import escape
from django.utils.safestring import mark_safe
from django.utils.encoding import smart_text
from django.utils.translation import ugettext as _
from django.db.models import Model
from django.conf import settings
from django import template, VERSION
from six import wraps

if VERSION >= (3, 0):
from django.utils.translation import gettext as _
else:
from django.utils.translation import ugettext as _

if VERSION >= (2, 0):
from django.urls import (reverse, resolve, NoReverseMatch, Resolver404)
else:
Expand Down
28 changes: 15 additions & 13 deletions tests/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@

from __future__ import unicode_literals

import django.contrib.auth.views

from django import VERSION

if VERSION >= (2, 1):
from django.contrib.auth.views import LoginView
login = LoginView.as_view()
else:
from django.contrib.auth.views import login

if VERSION < (1, 8): # pragma: nocover
from django.conf.urls import url, include, patterns
Expand All @@ -31,28 +36,25 @@
elif VERSION < (2, 0):
from django.conf.urls import url, include
nsurlpatters = [
url(r'^login2$', django.contrib.auth.views.login, name='login2_url'),
url(r'^login2$', login, name='login2_url'),
]

urlpatterns = [
url(r'^login$', django.contrib.auth.views.login, name='login_url'),
url(r'^login/(?P<slug>[-_\w]+)$', django.contrib.auth.views.login,
name='login_args_url'),
url(r'^login/user/(?P<user_id>\S+)$', django.contrib.auth.views.login,
name='login_kwargs_url'),
url(r'^login$', login, name='login_url'),
url(r'^login/(?P<slug>[-_\w]+)$', login, name='login_args_url'),
url(r'^login/user/(?P<user_id>\S+)$', login, name='login_kwargs_url'),
url(r'^ns/', include(nsurlpatters, namespace='ns')),
]
else:
from django.urls import include, path, re_path
nsurlpatters = [
path('login2', django.contrib.auth.views.login, name='login2_url'),
path('login2', login, name='login2_url'),
]

urlpatterns = [
path('login', django.contrib.auth.views.login, name='login_url'),
re_path(r'^login/(?P<slug>[-_\w]+)$', django.contrib.auth.views.login,
name='login_args_url'),
re_path(r'^login/user/(?P<user_id>\S+)$',
django.contrib.auth.views.login, name='login_kwargs_url'),
path('login', login, name='login_url'),
re_path(r'^login/(?P<slug>[-_\w]+)$', login, name='login_args_url'),
re_path(r'^login/user/(?P<user_id>\S+)$', login,
name='login_kwargs_url'),
path('ns/', include((nsurlpatters, 'ns'), namespace='ns')),
]

0 comments on commit 68de971

Please sign in to comment.