Skip to content

Commit

Permalink
refactor: Use django.urls.re_path instead of deprecated django.conf.u…
Browse files Browse the repository at this point in the history
…rls.url (#112)

Use `django.urls.re_path()` when available, instead of the deprecated `django.conf.urls.url()`.

* `re_path()` is available since Django 2.0.
* `url()` will be removed in Django 4.0.
  • Loading branch information
mathiasertl authored Oct 11, 2020
1 parent fa48985 commit 9bb736a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions django_object_actions/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from functools import wraps
from itertools import chain

from django.conf.urls import url
from django.contrib import messages
from django.contrib.admin.utils import unquote
from django.db.models.query import QuerySet
Expand All @@ -11,6 +10,11 @@
from django.views.generic.detail import SingleObjectMixin
from django.views.generic.list import MultipleObjectMixin

try:
from django.urls import re_path
except ImportError:
from django.conf.urls import url as re_path # DJANGO1.11

try:
from django.urls import reverse
except ImportError:
Expand Down Expand Up @@ -127,7 +131,7 @@ def _get_action_urls(self):
return [
# change, supports the same pks the admin does
# https://github.com/django/django/blob/stable/1.10.x/django/contrib/admin/options.py#L555
url(
re_path(
r"^(?P<pk>.+)/actions/(?P<tool>\w+)/$",
self.admin_site.admin_view( # checks permissions
ChangeActionView.as_view(
Expand All @@ -140,7 +144,7 @@ def _get_action_urls(self):
name=model_actions_url_name,
),
# changelist
url(
re_path(
r"^actions/(?P<tool>\w+)/$",
self.admin_site.admin_view( # checks permissions
ChangeListActionView.as_view(
Expand Down

0 comments on commit 9bb736a

Please sign in to comment.