[urls] Import re_path with a more pythonic fallback

This commit is contained in:
Valentin Samir 2021-06-19 16:17:30 +02:00
parent 956bec1178
commit 198308031b
2 changed files with 9 additions and 10 deletions

View file

@ -16,12 +16,11 @@ Including another URLconf
import django import django
if django.VERSION < (2,): try:
from django.conf.urls import url
re_path = url
else:
from django.urls import re_path from django.urls import re_path
except ImportError:
# re_path is not available in Django 2
from django.conf.urls import url as re_pa
from django.conf.urls import url, include from django.conf.urls import url, include
from django.contrib import admin from django.contrib import admin

View file

@ -13,12 +13,12 @@
import django import django
if django.VERSION < (2,):
from django.conf.urls import url
re_path = url
else:
from django.urls import re_path
try:
from django.urls import re_path
except ImportError:
# re_path is not available in Django 2
from django.conf.urls import url as re_path
from django.conf.urls import url from django.conf.urls import url
from django.views.generic import RedirectView from django.views.generic import RedirectView