From 01ee36ae5980914993b9f182b7b4e67f2ff0c137 Mon Sep 17 00:00:00 2001 From: Ignacio Catalina Date: Wed, 9 Dec 2015 03:00:03 +0000 Subject: [PATCH] Remove patterns('', as it's deprecated in django 1.9 and was causing errors in the unittest. Fixes #268. --- docs/public/release_notes.rst | 1 + hvad/admin.py | 12 ++++++------ hvad/test_utils/project/urls.py | 8 ++++---- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/docs/public/release_notes.rst b/docs/public/release_notes.rst index 99055f07..34d24d6b 100644 --- a/docs/public/release_notes.rst +++ b/docs/public/release_notes.rst @@ -32,6 +32,7 @@ Fixes: - REST framework translation support now uses ``update_fields`` to reduce the number of queries when updating an object. +- Admin no longer uses deprecated ``patterns`` function — :issue:`268`. .. release 1.4.0 diff --git a/hvad/admin.py b/hvad/admin.py index f5f8f2e2..b7f521cd 100644 --- a/hvad/admin.py +++ b/hvad/admin.py @@ -125,14 +125,14 @@ def get_url(self, obj, lang=None, get={}): def get_urls(self): - from django.conf.urls import patterns, url + from django.conf.urls import url urlpatterns = super(TranslatableAdmin, self).get_urls() info = self.model._meta.app_label, self.model._meta.model_name - return patterns('', + return [ url(r'^(.+)/delete-translation/(.+)/$', self.admin_site.admin_view(self.delete_translation), name='%s_%s_delete_translation' % info), - ) + urlpatterns + ] + urlpatterns def get_form(self, request, obj=None, **kwargs): """ @@ -383,16 +383,16 @@ def get_formset(self, request, obj=None, **kwargs): return translatable_inlineformset_factory(language, self.parent_model, self.model, **defaults) def get_urls(self): - from django.conf.urls import patterns, url + from django.conf.urls import url urlpatterns = super(InlineModelAdmin, self).get_urls() info = self.model._meta.app_label, self.model._meta.module_name - return patterns('', + return [ url(r'^(.+)/delete-translation/(.+)/$', self.admin_site.admin_view(self.delete_translation), name='%s_%s_delete_translation' % info), - ) + urlpatterns + ] + urlpatterns def get_form(self, request, obj=None, **kwargs): """ diff --git a/hvad/test_utils/project/urls.py b/hvad/test_utils/project/urls.py index fe9f0fda..7191b32b 100644 --- a/hvad/test_utils/project/urls.py +++ b/hvad/test_utils/project/urls.py @@ -1,8 +1,8 @@ -from django.conf.urls import patterns, include +from django.conf.urls import include, url from django.contrib import admin admin.autodiscover() -urlpatterns = patterns('', - (r'^admin/', include(admin.site.urls)), -) +urlpatterns = [ + url(r'^admin/', include(admin.site.urls)), +]