From 198308031bfc240f73cf3899ab011ac378ede4e6 Mon Sep 17 00:00:00 2001 From: Valentin Samir Date: Sat, 19 Jun 2021 16:17:30 +0200 Subject: [PATCH] [urls] Import re_path with a more pythonic fallback --- cas_server/tests/urls.py | 9 ++++----- cas_server/urls.py | 10 +++++----- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/cas_server/tests/urls.py b/cas_server/tests/urls.py index b95c228..ac8295f 100644 --- a/cas_server/tests/urls.py +++ b/cas_server/tests/urls.py @@ -16,12 +16,11 @@ Including another URLconf import django -if django.VERSION < (2,): - from django.conf.urls import url - re_path = url -else: +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_pa from django.conf.urls import url, include from django.contrib import admin diff --git a/cas_server/urls.py b/cas_server/urls.py index 680c61e..301157c 100644 --- a/cas_server/urls.py +++ b/cas_server/urls.py @@ -13,12 +13,12 @@ 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.views.generic import RedirectView