From ea0921fe0456f4466a66e62d59abcd635ccb3fb8 Mon Sep 17 00:00:00 2001 From: Bittu Date: Mon, 29 Jul 2024 18:55:40 +0530 Subject: [PATCH 1/5] removed django.utils.six intead directly imported six --- src/dal/views.py | 2 +- src/dal_contenttypes/fields.py | 2 +- src/dal_queryset_sequence/widgets.py | 2 +- src/dal_select2/views.py | 2 +- src/dal_select2/widgets.py | 2 +- src/dal_select2_queryset_sequence/views.py | 2 +- src/dal_select2_taggit/widgets.py | 2 +- test_project/select2_generic_foreign_key/test_forms.py | 2 +- test_project/select2_generic_m2m/test_forms.py | 2 +- test_project/select2_list/test_functional.py | 2 +- test_project/select2_tagging/test_forms.py | 2 +- test_project/select2_taggit/test_forms.py | 2 +- test_project/tests/test_widgets.py | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/dal/views.py b/src/dal/views.py index d63f135d3..18d6b61e2 100644 --- a/src/dal/views.py +++ b/src/dal/views.py @@ -7,7 +7,7 @@ from django.contrib.auth import get_permission_codename from django.core.exceptions import ImproperlyConfigured from django.http import HttpResponseBadRequest, HttpResponseNotAllowed -from django.utils import six +import six from django.views.generic.list import BaseListView diff --git a/src/dal_contenttypes/fields.py b/src/dal_contenttypes/fields.py index e516f5486..335f73871 100644 --- a/src/dal_contenttypes/fields.py +++ b/src/dal_contenttypes/fields.py @@ -1,7 +1,7 @@ """Model choice fields that take a ContentType too: for generic relations.""" from django.contrib.contenttypes.models import ContentType -from django.utils import six +import six class ContentTypeModelFieldMixin(object): diff --git a/src/dal_queryset_sequence/widgets.py b/src/dal_queryset_sequence/widgets.py index d7e9b69e8..6dbdf826b 100644 --- a/src/dal_queryset_sequence/widgets.py +++ b/src/dal_queryset_sequence/widgets.py @@ -8,7 +8,7 @@ from django import forms from django.contrib.contenttypes.models import ContentType -from django.utils import six +import six class QuerySetSequenceSelectMixin(WidgetMixin): diff --git a/src/dal_select2/views.py b/src/dal_select2/views.py index 83719daed..510f28cc9 100644 --- a/src/dal_select2/views.py +++ b/src/dal_select2/views.py @@ -7,7 +7,7 @@ from django import http from django.core.exceptions import ImproperlyConfigured -from django.utils import six +import six from django.utils.translation import ugettext as _ from django.views.generic.list import View diff --git a/src/dal_select2/widgets.py b/src/dal_select2/widgets.py index 2ba6363cf..b753975e6 100644 --- a/src/dal_select2/widgets.py +++ b/src/dal_select2/widgets.py @@ -14,7 +14,7 @@ from django.contrib.admin.widgets import SELECT2_TRANSLATIONS except ImportError: SELECT2_TRANSLATIONS = {} -from django.utils import six +import six from django.utils import translation diff --git a/src/dal_select2_queryset_sequence/views.py b/src/dal_select2_queryset_sequence/views.py index cec8e70ce..81008a9a4 100644 --- a/src/dal_select2_queryset_sequence/views.py +++ b/src/dal_select2_queryset_sequence/views.py @@ -7,7 +7,7 @@ from queryset_sequence import QuerySetSequence from django.template.defaultfilters import capfirst -from django.utils import six +import six from django.db.models import Q from functools import reduce diff --git a/src/dal_select2_taggit/widgets.py b/src/dal_select2_taggit/widgets.py index 5ec95c5b4..467624f16 100644 --- a/src/dal_select2_taggit/widgets.py +++ b/src/dal_select2_taggit/widgets.py @@ -3,7 +3,7 @@ from dal_select2.widgets import TagSelect2 from django import VERSION -from django.utils import six +import six class TaggitSelect2(TagSelect2): diff --git a/test_project/select2_generic_foreign_key/test_forms.py b/test_project/select2_generic_foreign_key/test_forms.py index 408bc0a34..6a47c234d 100644 --- a/test_project/select2_generic_foreign_key/test_forms.py +++ b/test_project/select2_generic_foreign_key/test_forms.py @@ -7,7 +7,7 @@ from django.urls import reverse except ImportError: from django.core.urlresolvers import reverse -from django.utils import six +import six from queryset_sequence import QuerySetSequence diff --git a/test_project/select2_generic_m2m/test_forms.py b/test_project/select2_generic_m2m/test_forms.py index 087a90213..f77d7f75a 100644 --- a/test_project/select2_generic_m2m/test_forms.py +++ b/test_project/select2_generic_m2m/test_forms.py @@ -8,7 +8,7 @@ from django.urls import reverse except ImportError: from django.core.urlresolvers import reverse -from django.utils import six +import six from queryset_sequence import QuerySetSequence diff --git a/test_project/select2_list/test_functional.py b/test_project/select2_list/test_functional.py index 83ccc24d4..c4a2a717e 100644 --- a/test_project/select2_list/test_functional.py +++ b/test_project/select2_list/test_functional.py @@ -4,7 +4,7 @@ from dal_select2.test import Select2Story -from django.utils import six +import six from .models import TModel diff --git a/test_project/select2_tagging/test_forms.py b/test_project/select2_tagging/test_forms.py index 9f009c686..a8c5dbd79 100644 --- a/test_project/select2_tagging/test_forms.py +++ b/test_project/select2_tagging/test_forms.py @@ -5,7 +5,7 @@ from django.urls import reverse except ImportError: from django.core.urlresolvers import reverse -from django.utils import six +import six from tagging.models import Tag diff --git a/test_project/select2_taggit/test_forms.py b/test_project/select2_taggit/test_forms.py index 7cf22196d..f1144d200 100644 --- a/test_project/select2_taggit/test_forms.py +++ b/test_project/select2_taggit/test_forms.py @@ -6,7 +6,7 @@ from django.urls import reverse except ImportError: from django.core.urlresolvers import reverse -from django.utils import six +import six from taggit.models import Tag diff --git a/test_project/tests/test_widgets.py b/test_project/tests/test_widgets.py index b2caceda9..41507fc5a 100644 --- a/test_project/tests/test_widgets.py +++ b/test_project/tests/test_widgets.py @@ -13,7 +13,7 @@ except ImportError: from django.core.urlresolvers import reverse from django.test.utils import override_settings -from django.utils import six +import six import mock From dd238001bc49cef1feaf5ceae64e2b9feca40b49 Mon Sep 17 00:00:00 2001 From: Bittu Date: Mon, 29 Jul 2024 19:07:35 +0530 Subject: [PATCH 2/5] removed the remaining issue --- src/dal/widgets.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dal/widgets.py b/src/dal/widgets.py index 9cf2187b5..d6976c3ce 100644 --- a/src/dal/widgets.py +++ b/src/dal/widgets.py @@ -11,7 +11,7 @@ from django.urls import reverse except ImportError: from django.core.urlresolvers import reverse -from django.utils import six +import six from django.utils.safestring import mark_safe From 7309f2dcfe35ace44bd2c2967991af7eaab9424a Mon Sep 17 00:00:00 2001 From: raybittuiq Date: Thu, 14 Nov 2024 17:01:22 +0530 Subject: [PATCH 3/5] ran django upgrade --- src/dal/test/case.py | 2 +- src/dal/views.py | 2 +- src/dal/widgets.py | 2 +- src/dal_queryset_sequence/fields.py | 4 +- src/dal_select2/__init__.py | 1 - src/dal_select2/views.py | 2 +- src/dal_select2_queryset_sequence/fields.py | 4 +- test_project/custom_select2/__init__.py | 1 - test_project/custom_select2/admin.py | 2 +- test_project/custom_select2/urls.py | 6 +-- .../forward_different_fields/admin.py | 2 +- test_project/forward_different_fields/urls.py | 6 +-- test_project/linked_data/__init__.py | 1 - test_project/linked_data/admin.py | 2 +- test_project/linked_data/test_views.py | 10 ++--- test_project/linked_data/urls.py | 6 +-- test_project/rename_forward/__init__.py | 1 - test_project/rename_forward/admin.py | 2 +- test_project/rename_forward/urls.py | 6 +-- test_project/secure_data/__init__.py | 1 - test_project/secure_data/admin.py | 2 +- test_project/secure_data/urls.py | 6 +-- test_project/select2_foreign_key/__init__.py | 1 - test_project/select2_foreign_key/admin.py | 2 +- test_project/select2_foreign_key/urls.py | 6 +-- .../select2_generic_foreign_key/__init__.py | 1 - .../select2_generic_foreign_key/admin.py | 2 +- .../select2_generic_foreign_key/test_forms.py | 2 +- .../select2_generic_foreign_key/urls.py | 6 +-- test_project/select2_generic_m2m/__init__.py | 1 - test_project/select2_generic_m2m/admin.py | 2 +- .../select2_generic_m2m/test_forms.py | 2 +- test_project/select2_generic_m2m/urls.py | 10 ++--- test_project/select2_gm2m/__init__.py | 1 - test_project/select2_gm2m/admin.py | 2 +- test_project/select2_gm2m/urls.py | 10 ++--- test_project/select2_list/admin.py | 2 +- test_project/select2_list/urls.py | 6 +-- test_project/select2_many_to_many/__init__.py | 1 - test_project/select2_many_to_many/admin.py | 2 +- test_project/select2_many_to_many/urls.py | 10 ++--- test_project/select2_nestedadmin/__init__.py | 1 - test_project/select2_nestedadmin/admin.py | 2 +- test_project/select2_nestedadmin/urls.py | 6 +-- test_project/select2_one_to_one/__init__.py | 1 - test_project/select2_one_to_one/admin.py | 2 +- test_project/select2_one_to_one/urls.py | 10 ++--- test_project/select2_outside_admin/urls.py | 6 +-- test_project/select2_outside_admin/views.py | 2 +- test_project/select2_tagging/admin.py | 2 +- test_project/select2_tagging/test_forms.py | 2 +- test_project/select2_tagging/urls.py | 6 +-- test_project/select2_taggit/admin.py | 2 +- test_project/select2_taggit/test_forms.py | 2 +- test_project/select2_taggit/urls.py | 6 +-- test_project/settings/base.py | 1 - test_project/tests/test_widgets.py | 8 ++-- test_project/urls.py | 42 +++++++++---------- 58 files changed, 114 insertions(+), 127 deletions(-) diff --git a/src/dal/test/case.py b/src/dal/test/case.py index 766e91487..eb727ae3e 100644 --- a/src/dal/test/case.py +++ b/src/dal/test/case.py @@ -10,7 +10,7 @@ try: from django.urls import reverse except ImportError: - from django.core.urlresolvers import reverse + from django.urls import reverse from django.utils import six from splinter import Browser diff --git a/src/dal/views.py b/src/dal/views.py index 18d6b61e2..c916aea96 100644 --- a/src/dal/views.py +++ b/src/dal/views.py @@ -104,7 +104,7 @@ def create_object(self, text): def has_add_permission(self, request): """Return True if the user has the permission to add a model.""" if django.VERSION < (2, 0, 0): - auth = request.user.is_authenticated() + auth = request.user.is_authenticated else: auth = request.user.is_authenticated diff --git a/src/dal/widgets.py b/src/dal/widgets.py index d6976c3ce..ffc243942 100644 --- a/src/dal/widgets.py +++ b/src/dal/widgets.py @@ -10,7 +10,7 @@ try: from django.urls import reverse except ImportError: - from django.core.urlresolvers import reverse + from django.urls import reverse import six from django.utils.safestring import mark_safe diff --git a/src/dal_queryset_sequence/fields.py b/src/dal_queryset_sequence/fields.py index 944d32959..08daa872f 100644 --- a/src/dal_queryset_sequence/fields.py +++ b/src/dal_queryset_sequence/fields.py @@ -7,7 +7,7 @@ from django import forms from django.contrib.contenttypes.models import ContentType -from django.conf.urls import url +from django.urls import re_path from queryset_sequence import QuerySetSequence @@ -162,5 +162,5 @@ def as_url(self, form): AutoView = type('Autoview{}{}'.format(form.__name__, self.field_id), (self.view_obj,), {}) - return url(r'^{}_{}_autocomp$'.format(form.__name__, self.field_id), + return re_path(r'^{}_{}_autocomp$'.format(form.__name__, self.field_id), AutoView.as_view(queryset=self.queryset), name=url_name) diff --git a/src/dal_select2/__init__.py b/src/dal_select2/__init__.py index 5963b4997..a39af322a 100644 --- a/src/dal_select2/__init__.py +++ b/src/dal_select2/__init__.py @@ -1,3 +1,2 @@ """Select2 support for DAL.""" -default_app_config = 'dal_select2.apps.DefaultApp' diff --git a/src/dal_select2/views.py b/src/dal_select2/views.py index 510f28cc9..ec4b059ad 100644 --- a/src/dal_select2/views.py +++ b/src/dal_select2/views.py @@ -8,7 +8,7 @@ from django import http from django.core.exceptions import ImproperlyConfigured import six -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from django.views.generic.list import View diff --git a/src/dal_select2_queryset_sequence/fields.py b/src/dal_select2_queryset_sequence/fields.py index 1a10e59e3..2dc097a4d 100644 --- a/src/dal_select2_queryset_sequence/fields.py +++ b/src/dal_select2_queryset_sequence/fields.py @@ -1,4 +1,4 @@ -from django.conf.urls import url +from django.urls import re_path from dal_queryset_sequence.fields import QuerySetSequenceModelField @@ -44,5 +44,5 @@ def as_url(self, form): (Select2QuerySetSequenceAutoView,), {'model_choice': self.model_choice}) # send to the view the model and filter list - return url(r'^{}_{}_autocomp$'.format(form.__name__, self.field_id), + return re_path(r'^{}_{}_autocomp$'.format(form.__name__, self.field_id), AutoView.as_view(), name=url_name) diff --git a/test_project/custom_select2/__init__.py b/test_project/custom_select2/__init__.py index 683e19cd1..e69de29bb 100644 --- a/test_project/custom_select2/__init__.py +++ b/test_project/custom_select2/__init__.py @@ -1 +0,0 @@ -default_app_config = 'custom_select2.apps.TestApp' diff --git a/test_project/custom_select2/admin.py b/test_project/custom_select2/admin.py index ea547b699..ec9afca98 100644 --- a/test_project/custom_select2/admin.py +++ b/test_project/custom_select2/admin.py @@ -10,7 +10,7 @@ class TestInline(admin.TabularInline): fk_name = 'for_inline' +@admin.register(TModel) class TestAdmin(admin.ModelAdmin): form = TForm inlines = [TestInline] -admin.site.register(TModel, TestAdmin) diff --git a/test_project/custom_select2/urls.py b/test_project/custom_select2/urls.py index a2cfc0af0..d310e0352 100644 --- a/test_project/custom_select2/urls.py +++ b/test_project/custom_select2/urls.py @@ -1,13 +1,13 @@ from dal import autocomplete -from django.conf.urls import url +from django.urls import path from .models import TModel urlpatterns = [ - url( - 'test-autocomplete/$', + path( + 'test-autocomplete/', autocomplete.Select2QuerySetView.as_view(model=TModel), name='select2_fk', ), diff --git a/test_project/forward_different_fields/admin.py b/test_project/forward_different_fields/admin.py index 2870325da..4f2e64105 100644 --- a/test_project/forward_different_fields/admin.py +++ b/test_project/forward_different_fields/admin.py @@ -10,7 +10,7 @@ class TestInline(admin.TabularInline): fk_name = 'for_inline' +@admin.register(TModel) class TestAdmin(admin.ModelAdmin): form = TForm -admin.site.register(TModel, TestAdmin) diff --git a/test_project/forward_different_fields/urls.py b/test_project/forward_different_fields/urls.py index 1ec6d9398..f5acb506d 100644 --- a/test_project/forward_different_fields/urls.py +++ b/test_project/forward_different_fields/urls.py @@ -1,6 +1,6 @@ from dal import autocomplete -from django.conf.urls import url +from django.urls import path class ListWithForwardsView(autocomplete.Select2ListView): @@ -19,8 +19,8 @@ def get_list(self): urlpatterns = [ - url( - '^forward_different_fields/$', + path( + 'forward_different_fields/', ListWithForwardsView.as_view(), name='forward_different_fields' ), diff --git a/test_project/linked_data/__init__.py b/test_project/linked_data/__init__.py index 1e8feb511..e69de29bb 100644 --- a/test_project/linked_data/__init__.py +++ b/test_project/linked_data/__init__.py @@ -1 +0,0 @@ -default_app_config = 'linked_data.apps.TestApp' diff --git a/test_project/linked_data/admin.py b/test_project/linked_data/admin.py index ea547b699..ec9afca98 100644 --- a/test_project/linked_data/admin.py +++ b/test_project/linked_data/admin.py @@ -10,7 +10,7 @@ class TestInline(admin.TabularInline): fk_name = 'for_inline' +@admin.register(TModel) class TestAdmin(admin.ModelAdmin): form = TForm inlines = [TestInline] -admin.site.register(TModel, TestAdmin) diff --git a/test_project/linked_data/test_views.py b/test_project/linked_data/test_views.py index 360477e75..038bdf3e2 100644 --- a/test_project/linked_data/test_views.py +++ b/test_project/linked_data/test_views.py @@ -6,8 +6,8 @@ try: from django.urls import reverse except ImportError: - from django.core.urlresolvers import reverse -from django.utils.encoding import force_text + from django.urls import reverse +from django.utils.encoding import force_str from .models import TModel from .urls import LinkedDataView @@ -24,7 +24,7 @@ def test_no_data(self): response = LinkedDataView.as_view(model=TModel)(request) self.assertEqual(response.status_code, 200) - self.assertJSONEqual(force_text(response.content), + self.assertJSONEqual(force_str(response.content), '{"results": [], "pagination": {"more": false}}') def test_not_dict(self): @@ -34,7 +34,7 @@ def test_not_dict(self): response = LinkedDataView.as_view(model=TModel)(request) self.assertEqual(response.status_code, 400) - self.assertEqual(force_text(response.content), 'Not a JSON object') + self.assertEqual(force_str(response.content), 'Not a JSON object') def test_invalid_json(self): request = self.factory.get( @@ -43,7 +43,7 @@ def test_invalid_json(self): response = LinkedDataView.as_view(model=TModel)(request) self.assertEqual(response.status_code, 400) - self.assertEqual(force_text(response.content), 'Invalid JSON data') + self.assertEqual(force_str(response.content), 'Invalid JSON data') def test_invalid_method(self): request = self.factory.put(reverse('linked_data')) diff --git a/test_project/linked_data/urls.py b/test_project/linked_data/urls.py index 24f79ecae..c000e9972 100644 --- a/test_project/linked_data/urls.py +++ b/test_project/linked_data/urls.py @@ -1,6 +1,6 @@ from dal import autocomplete -from django.conf.urls import url +from django.urls import path from .models import TModel @@ -17,8 +17,8 @@ def get_queryset(self): urlpatterns = [ - url( - '^linked_data/$', + path( + 'linked_data/', LinkedDataView.as_view(model=TModel), name='linked_data' ), diff --git a/test_project/rename_forward/__init__.py b/test_project/rename_forward/__init__.py index e2309d9a3..e69de29bb 100644 --- a/test_project/rename_forward/__init__.py +++ b/test_project/rename_forward/__init__.py @@ -1 +0,0 @@ -default_app_config = 'rename_forward.apps.TestApp' diff --git a/test_project/rename_forward/admin.py b/test_project/rename_forward/admin.py index ea547b699..ec9afca98 100644 --- a/test_project/rename_forward/admin.py +++ b/test_project/rename_forward/admin.py @@ -10,7 +10,7 @@ class TestInline(admin.TabularInline): fk_name = 'for_inline' +@admin.register(TModel) class TestAdmin(admin.ModelAdmin): form = TForm inlines = [TestInline] -admin.site.register(TModel, TestAdmin) diff --git a/test_project/rename_forward/urls.py b/test_project/rename_forward/urls.py index d57c7e00f..b4b0ee388 100644 --- a/test_project/rename_forward/urls.py +++ b/test_project/rename_forward/urls.py @@ -1,6 +1,6 @@ from dal import autocomplete -from django.conf.urls import url +from django.urls import path from .models import TModel @@ -22,8 +22,8 @@ def get_queryset(self): urlpatterns = [ - url( - '^linked_data/$', + path( + 'linked_data/', LinkedDataView.as_view(model=TModel), name='linked_data_rf' ), diff --git a/test_project/secure_data/__init__.py b/test_project/secure_data/__init__.py index bcf745480..e69de29bb 100644 --- a/test_project/secure_data/__init__.py +++ b/test_project/secure_data/__init__.py @@ -1 +0,0 @@ -default_app_config = 'secure_data.apps.TestApp' diff --git a/test_project/secure_data/admin.py b/test_project/secure_data/admin.py index b5d9bd1cd..abaf83095 100644 --- a/test_project/secure_data/admin.py +++ b/test_project/secure_data/admin.py @@ -26,7 +26,7 @@ class TestInline(SecureFormMixin, admin.TabularInline): form = TForm +@admin.register(TModel) class TestAdmin(SecureFormMixin, admin.ModelAdmin): inlines = [TestInline] form = TForm -admin.site.register(TModel, TestAdmin) diff --git a/test_project/secure_data/urls.py b/test_project/secure_data/urls.py index 4b1b2f81b..8dc6317ae 100644 --- a/test_project/secure_data/urls.py +++ b/test_project/secure_data/urls.py @@ -1,6 +1,6 @@ from dal import autocomplete -from django.conf.urls import url +from django.urls import path from .models import TModel @@ -11,8 +11,8 @@ def get_queryset(self): urlpatterns = [ - url( - '^secure-data/$', + path( + 'secure-data/', SecureDataView.as_view(), name='secure_data', ), diff --git a/test_project/select2_foreign_key/__init__.py b/test_project/select2_foreign_key/__init__.py index 4fb344428..e69de29bb 100644 --- a/test_project/select2_foreign_key/__init__.py +++ b/test_project/select2_foreign_key/__init__.py @@ -1 +0,0 @@ -default_app_config = 'select2_foreign_key.apps.TestApp' diff --git a/test_project/select2_foreign_key/admin.py b/test_project/select2_foreign_key/admin.py index ea547b699..ec9afca98 100644 --- a/test_project/select2_foreign_key/admin.py +++ b/test_project/select2_foreign_key/admin.py @@ -10,7 +10,7 @@ class TestInline(admin.TabularInline): fk_name = 'for_inline' +@admin.register(TModel) class TestAdmin(admin.ModelAdmin): form = TForm inlines = [TestInline] -admin.site.register(TModel, TestAdmin) diff --git a/test_project/select2_foreign_key/urls.py b/test_project/select2_foreign_key/urls.py index a2cfc0af0..d310e0352 100644 --- a/test_project/select2_foreign_key/urls.py +++ b/test_project/select2_foreign_key/urls.py @@ -1,13 +1,13 @@ from dal import autocomplete -from django.conf.urls import url +from django.urls import path from .models import TModel urlpatterns = [ - url( - 'test-autocomplete/$', + path( + 'test-autocomplete/', autocomplete.Select2QuerySetView.as_view(model=TModel), name='select2_fk', ), diff --git a/test_project/select2_generic_foreign_key/__init__.py b/test_project/select2_generic_foreign_key/__init__.py index 834b93771..e69de29bb 100644 --- a/test_project/select2_generic_foreign_key/__init__.py +++ b/test_project/select2_generic_foreign_key/__init__.py @@ -1 +0,0 @@ -default_app_config = 'select2_generic_foreign_key.apps.TestApp' diff --git a/test_project/select2_generic_foreign_key/admin.py b/test_project/select2_generic_foreign_key/admin.py index ea547b699..ec9afca98 100644 --- a/test_project/select2_generic_foreign_key/admin.py +++ b/test_project/select2_generic_foreign_key/admin.py @@ -10,7 +10,7 @@ class TestInline(admin.TabularInline): fk_name = 'for_inline' +@admin.register(TModel) class TestAdmin(admin.ModelAdmin): form = TForm inlines = [TestInline] -admin.site.register(TModel, TestAdmin) diff --git a/test_project/select2_generic_foreign_key/test_forms.py b/test_project/select2_generic_foreign_key/test_forms.py index 6a47c234d..ee59c2422 100644 --- a/test_project/select2_generic_foreign_key/test_forms.py +++ b/test_project/select2_generic_foreign_key/test_forms.py @@ -6,7 +6,7 @@ try: from django.urls import reverse except ImportError: - from django.core.urlresolvers import reverse + from django.urls import reverse import six from queryset_sequence import QuerySetSequence diff --git a/test_project/select2_generic_foreign_key/urls.py b/test_project/select2_generic_foreign_key/urls.py index 8a033146c..fce91bdd9 100644 --- a/test_project/select2_generic_foreign_key/urls.py +++ b/test_project/select2_generic_foreign_key/urls.py @@ -1,6 +1,6 @@ from dal import autocomplete -from django.conf.urls import url +from django.urls import path from django.contrib.auth.models import Group from django.views import generic @@ -9,8 +9,8 @@ urlpatterns = [ - url( - 'test/(?P\d+)/$', + path( + 'test//', generic.UpdateView.as_view( model=TModel, form_class=TForm, diff --git a/test_project/select2_generic_m2m/__init__.py b/test_project/select2_generic_m2m/__init__.py index d88b77dee..e69de29bb 100644 --- a/test_project/select2_generic_m2m/__init__.py +++ b/test_project/select2_generic_m2m/__init__.py @@ -1 +0,0 @@ -default_app_config = 'select2_generic_m2m.apps.TestApp' diff --git a/test_project/select2_generic_m2m/admin.py b/test_project/select2_generic_m2m/admin.py index ea547b699..ec9afca98 100644 --- a/test_project/select2_generic_m2m/admin.py +++ b/test_project/select2_generic_m2m/admin.py @@ -10,7 +10,7 @@ class TestInline(admin.TabularInline): fk_name = 'for_inline' +@admin.register(TModel) class TestAdmin(admin.ModelAdmin): form = TForm inlines = [TestInline] -admin.site.register(TModel, TestAdmin) diff --git a/test_project/select2_generic_m2m/test_forms.py b/test_project/select2_generic_m2m/test_forms.py index f77d7f75a..ff325b801 100644 --- a/test_project/select2_generic_m2m/test_forms.py +++ b/test_project/select2_generic_m2m/test_forms.py @@ -7,7 +7,7 @@ try: from django.urls import reverse except ImportError: - from django.core.urlresolvers import reverse + from django.urls import reverse import six from queryset_sequence import QuerySetSequence diff --git a/test_project/select2_generic_m2m/urls.py b/test_project/select2_generic_m2m/urls.py index 09321201a..3aa045b39 100644 --- a/test_project/select2_generic_m2m/urls.py +++ b/test_project/select2_generic_m2m/urls.py @@ -1,6 +1,6 @@ from dal import autocomplete -from django.conf.urls import url +from django.urls import path from django.contrib.auth.models import Group from django.views import generic @@ -9,8 +9,8 @@ urlpatterns = [ - url( - '^select2-generic-m2m/$', + path( + 'select2-generic-m2m/', autocomplete.Select2QuerySetSequenceView.as_view( queryset=autocomplete.QuerySetSequence( Group.objects.all(), @@ -19,8 +19,8 @@ ), name='select2_generic_m2m', ), - url( - 'test/(?P\d+)/$', + path( + 'test//', generic.UpdateView.as_view( model=TModel, form_class=TForm, diff --git a/test_project/select2_gm2m/__init__.py b/test_project/select2_gm2m/__init__.py index 08de4ec97..e69de29bb 100644 --- a/test_project/select2_gm2m/__init__.py +++ b/test_project/select2_gm2m/__init__.py @@ -1 +0,0 @@ -default_app_config = 'select2_gm2m.apps.TestApp' diff --git a/test_project/select2_gm2m/admin.py b/test_project/select2_gm2m/admin.py index ea547b699..ec9afca98 100644 --- a/test_project/select2_gm2m/admin.py +++ b/test_project/select2_gm2m/admin.py @@ -10,7 +10,7 @@ class TestInline(admin.TabularInline): fk_name = 'for_inline' +@admin.register(TModel) class TestAdmin(admin.ModelAdmin): form = TForm inlines = [TestInline] -admin.site.register(TModel, TestAdmin) diff --git a/test_project/select2_gm2m/urls.py b/test_project/select2_gm2m/urls.py index 7c6c5b16a..db09c32b9 100644 --- a/test_project/select2_gm2m/urls.py +++ b/test_project/select2_gm2m/urls.py @@ -1,6 +1,6 @@ from dal import autocomplete -from django.conf.urls import url +from django.urls import path from django.contrib.auth.models import Group from django.views import generic @@ -9,8 +9,8 @@ urlpatterns = [ - url( - '^select2_gm2m/$', + path( + 'select2_gm2m/', autocomplete.Select2QuerySetSequenceView.as_view( queryset=autocomplete.QuerySetSequence( Group.objects.all(), @@ -19,8 +19,8 @@ ), name='select2_gm2m', ), - url( - 'test/(?P\d+)/$', + path( + 'test//', generic.UpdateView.as_view( model=TModel, form_class=TForm, diff --git a/test_project/select2_list/admin.py b/test_project/select2_list/admin.py index ea547b699..ec9afca98 100644 --- a/test_project/select2_list/admin.py +++ b/test_project/select2_list/admin.py @@ -10,7 +10,7 @@ class TestInline(admin.TabularInline): fk_name = 'for_inline' +@admin.register(TModel) class TestAdmin(admin.ModelAdmin): form = TForm inlines = [TestInline] -admin.site.register(TModel, TestAdmin) diff --git a/test_project/select2_list/urls.py b/test_project/select2_list/urls.py index a8dd44f58..71b2943aa 100644 --- a/test_project/select2_list/urls.py +++ b/test_project/select2_list/urls.py @@ -1,11 +1,11 @@ -from django.conf.urls import url +from django.urls import path from .views import Select2ListViewAutocomplete urlpatterns = [ - url( - 'test-autocomplete/$', + path( + 'test-autocomplete/', Select2ListViewAutocomplete.as_view(), name='select2_list', ), diff --git a/test_project/select2_many_to_many/__init__.py b/test_project/select2_many_to_many/__init__.py index 81defdf81..e69de29bb 100644 --- a/test_project/select2_many_to_many/__init__.py +++ b/test_project/select2_many_to_many/__init__.py @@ -1 +0,0 @@ -default_app_config = 'select2_many_to_many.apps.TestApp' diff --git a/test_project/select2_many_to_many/admin.py b/test_project/select2_many_to_many/admin.py index ea547b699..ec9afca98 100644 --- a/test_project/select2_many_to_many/admin.py +++ b/test_project/select2_many_to_many/admin.py @@ -10,7 +10,7 @@ class TestInline(admin.TabularInline): fk_name = 'for_inline' +@admin.register(TModel) class TestAdmin(admin.ModelAdmin): form = TForm inlines = [TestInline] -admin.site.register(TModel, TestAdmin) diff --git a/test_project/select2_many_to_many/urls.py b/test_project/select2_many_to_many/urls.py index bf47d1299..dfa34af3b 100644 --- a/test_project/select2_many_to_many/urls.py +++ b/test_project/select2_many_to_many/urls.py @@ -1,6 +1,6 @@ from dal import autocomplete -from django.conf.urls import url +from django.urls import path from django.views import generic from .forms import TForm @@ -8,16 +8,16 @@ urlpatterns = [ - url( - 'test-autocomplete/$', + path( + 'test-autocomplete/', autocomplete.Select2QuerySetView.as_view( model=TModel, create_field='name', ), name='select2_many_to_many_autocomplete', ), - url( - 'test/(?P\d+)/$', + path( + 'test//', generic.UpdateView.as_view( model=TModel, form_class=TForm, diff --git a/test_project/select2_nestedadmin/__init__.py b/test_project/select2_nestedadmin/__init__.py index 6e12ca09f..e69de29bb 100644 --- a/test_project/select2_nestedadmin/__init__.py +++ b/test_project/select2_nestedadmin/__init__.py @@ -1 +0,0 @@ -default_app_config = 'select2_nestedadmin.apps.TestApp' diff --git a/test_project/select2_nestedadmin/admin.py b/test_project/select2_nestedadmin/admin.py index b9c132c1a..b7f7f1779 100644 --- a/test_project/select2_nestedadmin/admin.py +++ b/test_project/select2_nestedadmin/admin.py @@ -18,9 +18,9 @@ class TModelTwoInline(nested_admin.NestedStackedInline): extra = 1 +@admin.register(TModelOne) class TModelOneAdmin(nested_admin.NestedModelAdmin): model = TModelOne inlines = [TModelTwoInline] -admin.site.register(TModelOne, TModelOneAdmin) diff --git a/test_project/select2_nestedadmin/urls.py b/test_project/select2_nestedadmin/urls.py index 13d02f3e7..e5af19339 100644 --- a/test_project/select2_nestedadmin/urls.py +++ b/test_project/select2_nestedadmin/urls.py @@ -1,6 +1,6 @@ from dal import autocomplete -from django.conf.urls import url +from django.urls import path from .models import TModelThree @@ -24,8 +24,8 @@ def get_queryset(self): urlpatterns = [ - url( - '^linked_data/$', + path( + 'linked_data/', LinkedDataView.as_view(model=TModelThree), name='nested_linked_data' ), diff --git a/test_project/select2_one_to_one/__init__.py b/test_project/select2_one_to_one/__init__.py index 9ce71c705..e69de29bb 100644 --- a/test_project/select2_one_to_one/__init__.py +++ b/test_project/select2_one_to_one/__init__.py @@ -1 +0,0 @@ -default_app_config = 'select2_one_to_one.apps.TestApp' diff --git a/test_project/select2_one_to_one/admin.py b/test_project/select2_one_to_one/admin.py index ea547b699..ec9afca98 100644 --- a/test_project/select2_one_to_one/admin.py +++ b/test_project/select2_one_to_one/admin.py @@ -10,7 +10,7 @@ class TestInline(admin.TabularInline): fk_name = 'for_inline' +@admin.register(TModel) class TestAdmin(admin.ModelAdmin): form = TForm inlines = [TestInline] -admin.site.register(TModel, TestAdmin) diff --git a/test_project/select2_one_to_one/urls.py b/test_project/select2_one_to_one/urls.py index 2fdb27750..a70267a17 100644 --- a/test_project/select2_one_to_one/urls.py +++ b/test_project/select2_one_to_one/urls.py @@ -1,6 +1,6 @@ from dal import autocomplete -from django.conf.urls import url +from django.urls import path from django.views import generic from .forms import TForm @@ -8,16 +8,16 @@ urlpatterns = [ - url( - 'test-autocomplete/$', + path( + 'test-autocomplete/', autocomplete.Select2QuerySetView.as_view( model=TModel, create_field='name', ), name='select2_one_to_one_autocomplete', ), - url( - 'test/(?P\d+)/$', + path( + 'test//', generic.UpdateView.as_view( model=TModel, form_class=TForm, diff --git a/test_project/select2_outside_admin/urls.py b/test_project/select2_outside_admin/urls.py index 3ac844e55..4d16a62a2 100644 --- a/test_project/select2_outside_admin/urls.py +++ b/test_project/select2_outside_admin/urls.py @@ -1,11 +1,11 @@ -from django.conf.urls import url +from django.urls import path from .views import UpdateView urlpatterns = [ - url( - r'^$', + path( + '', UpdateView.as_view(), name='select2_outside_admin', ), diff --git a/test_project/select2_outside_admin/views.py b/test_project/select2_outside_admin/views.py index fc2eda8c7..0e9ca09f0 100644 --- a/test_project/select2_outside_admin/views.py +++ b/test_project/select2_outside_admin/views.py @@ -1,7 +1,7 @@ try: from django.urls import reverse_lazy except ImportError: - from django.core.urlresolvers import reverse_lazy + from django.urls import reverse_lazy from django.views import generic from select2_many_to_many.forms import TForm diff --git a/test_project/select2_tagging/admin.py b/test_project/select2_tagging/admin.py index ea547b699..ec9afca98 100644 --- a/test_project/select2_tagging/admin.py +++ b/test_project/select2_tagging/admin.py @@ -10,7 +10,7 @@ class TestInline(admin.TabularInline): fk_name = 'for_inline' +@admin.register(TModel) class TestAdmin(admin.ModelAdmin): form = TForm inlines = [TestInline] -admin.site.register(TModel, TestAdmin) diff --git a/test_project/select2_tagging/test_forms.py b/test_project/select2_tagging/test_forms.py index a8c5dbd79..841d12241 100644 --- a/test_project/select2_tagging/test_forms.py +++ b/test_project/select2_tagging/test_forms.py @@ -4,7 +4,7 @@ try: from django.urls import reverse except ImportError: - from django.core.urlresolvers import reverse + from django.urls import reverse import six from tagging.models import Tag diff --git a/test_project/select2_tagging/urls.py b/test_project/select2_tagging/urls.py index 588d80155..f8a22b5d9 100644 --- a/test_project/select2_tagging/urls.py +++ b/test_project/select2_tagging/urls.py @@ -1,13 +1,13 @@ from dal import autocomplete -from django.conf.urls import url +from django.urls import path from tagging.models import Tag urlpatterns = [ - url( - 'test-autocomplete/$', + path( + 'test-autocomplete/', autocomplete.Select2QuerySetView.as_view( queryset=Tag.objects.all(), ), diff --git a/test_project/select2_taggit/admin.py b/test_project/select2_taggit/admin.py index ea547b699..ec9afca98 100644 --- a/test_project/select2_taggit/admin.py +++ b/test_project/select2_taggit/admin.py @@ -10,7 +10,7 @@ class TestInline(admin.TabularInline): fk_name = 'for_inline' +@admin.register(TModel) class TestAdmin(admin.ModelAdmin): form = TForm inlines = [TestInline] -admin.site.register(TModel, TestAdmin) diff --git a/test_project/select2_taggit/test_forms.py b/test_project/select2_taggit/test_forms.py index f1144d200..62d806323 100644 --- a/test_project/select2_taggit/test_forms.py +++ b/test_project/select2_taggit/test_forms.py @@ -5,7 +5,7 @@ try: from django.urls import reverse except ImportError: - from django.core.urlresolvers import reverse + from django.urls import reverse import six from taggit.models import Tag diff --git a/test_project/select2_taggit/urls.py b/test_project/select2_taggit/urls.py index fb3770286..29677855f 100644 --- a/test_project/select2_taggit/urls.py +++ b/test_project/select2_taggit/urls.py @@ -1,13 +1,13 @@ from dal import autocomplete -from django.conf.urls import url +from django.urls import path from taggit.models import Tag urlpatterns = [ - url( - 'test-autocomplete/$', + path( + 'test-autocomplete/', autocomplete.Select2QuerySetView.as_view( queryset=Tag.objects.all(), ), diff --git a/test_project/settings/base.py b/test_project/settings/base.py index 649476440..ba3d0d01b 100644 --- a/test_project/settings/base.py +++ b/test_project/settings/base.py @@ -161,7 +161,6 @@ def get_databases(base_dir): LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' USE_I18N = True -USE_L10N = True USE_TZ = True DNS = os.environ.get('OPENSHIFT_APP_DNS', None), diff --git a/test_project/tests/test_widgets.py b/test_project/tests/test_widgets.py index 41507fc5a..2d9ebaca5 100644 --- a/test_project/tests/test_widgets.py +++ b/test_project/tests/test_widgets.py @@ -7,11 +7,11 @@ from django import forms from django import http from django import test -from django.conf.urls import url +from django.urls import path try: from django.urls import reverse except ImportError: - from django.core.urlresolvers import reverse + from django.urls import reverse from django.test.utils import override_settings import six @@ -19,8 +19,8 @@ urlpatterns = [ - url( - r'^test-url/$', + path( + 'test-url/', mock.Mock(), name='test_url' ), diff --git a/test_project/urls.py b/test_project/urls.py index 0db4b8576..bb2d41d6a 100644 --- a/test_project/urls.py +++ b/test_project/urls.py @@ -1,5 +1,5 @@ import django -from django.conf.urls import include, url +from django.urls import include, path, re_path from django.conf import settings from django.contrib import admin @@ -7,39 +7,39 @@ urlpatterns = [ - url(r'^$', views.IndexView.as_view()), + path('', views.IndexView.as_view()), - url(r'^admin/', admin.site.urls), - url(r'^login/', views.LoginView.as_view()), + re_path(r'^admin/', admin.site.urls), + re_path(r'^login/', views.LoginView.as_view()), - url(r'^secure_data/', include('secure_data.urls')), - url(r'^linked_data/', include('linked_data.urls')), - url(r'^rename_forward/', include('rename_forward.urls')), - url(r'^forward_different_fields/', + path('secure_data/', include('secure_data.urls')), + path('linked_data/', include('linked_data.urls')), + path('rename_forward/', include('rename_forward.urls')), + path('forward_different_fields/', include('forward_different_fields.urls')), - url(r'^select2_nestedadmin/', include('select2_nestedadmin.urls')), + path('select2_nestedadmin/', include('select2_nestedadmin.urls')), - url(r'^select2_foreign_key/', include('select2_foreign_key.urls')), - url(r'^select2_list/', include('select2_list.urls')), - url(r'^select2_generic_foreign_key/', + path('select2_foreign_key/', include('select2_foreign_key.urls')), + path('select2_list/', include('select2_list.urls')), + path('select2_generic_foreign_key/', include('select2_generic_foreign_key.urls')), - url(r'^select2_many_to_many/', + path('select2_many_to_many/', include('select2_many_to_many.urls')), - url(r'^select2_one_to_one/', include('select2_one_to_one.urls')), + path('select2_one_to_one/', include('select2_one_to_one.urls')), - url(r'^select2_outside_admin/', include('select2_outside_admin.urls')), - url(r'^select2_taggit/', include('select2_taggit.urls')), - url(r'^nested_admin/', include('nested_admin.urls')), + path('select2_outside_admin/', include('select2_outside_admin.urls')), + path('select2_taggit/', include('select2_taggit.urls')), + path('nested_admin/', include('nested_admin.urls')), ] if django.VERSION < (2, 0, 0): # pending upstream support urlpatterns += [ - url(r'^select2_tagging/', include('select2_tagging.urls')), - url(r'^select2_gm2m/', include('select2_gm2m.urls')), - url(r'^select2_generic_m2m/', include('select2_generic_m2m.urls')), + path('select2_tagging/', include('select2_tagging.urls')), + path('select2_gm2m/', include('select2_gm2m.urls')), + path('select2_generic_m2m/', include('select2_generic_m2m.urls')), ] if 'debug_toolbar' in settings.INSTALLED_APPS: import debug_toolbar - urlpatterns += [url(r'^__debug__/', include(debug_toolbar.urls)),] + urlpatterns += [path('__debug__/', include(debug_toolbar.urls)),] From 0e2e3b8b4b560e76e010d0948b967e2064ad9b42 Mon Sep 17 00:00:00 2001 From: raybittuiq Date: Thu, 14 Nov 2024 17:10:28 +0530 Subject: [PATCH 4/5] ran django uograde in only required files --- src/dal/test/case.py | 2 +- src/dal/views.py | 2 +- src/dal/widgets.py | 2 +- src/dal_queryset_sequence/fields.py | 4 ++-- src/dal_select2/__init__.py | 1 - src/dal_select2/views.py | 2 +- src/dal_select2_queryset_sequence/fields.py | 4 ++-- 7 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/dal/test/case.py b/src/dal/test/case.py index 766e91487..eb727ae3e 100644 --- a/src/dal/test/case.py +++ b/src/dal/test/case.py @@ -10,7 +10,7 @@ try: from django.urls import reverse except ImportError: - from django.core.urlresolvers import reverse + from django.urls import reverse from django.utils import six from splinter import Browser diff --git a/src/dal/views.py b/src/dal/views.py index 18d6b61e2..c916aea96 100644 --- a/src/dal/views.py +++ b/src/dal/views.py @@ -104,7 +104,7 @@ def create_object(self, text): def has_add_permission(self, request): """Return True if the user has the permission to add a model.""" if django.VERSION < (2, 0, 0): - auth = request.user.is_authenticated() + auth = request.user.is_authenticated else: auth = request.user.is_authenticated diff --git a/src/dal/widgets.py b/src/dal/widgets.py index d6976c3ce..ffc243942 100644 --- a/src/dal/widgets.py +++ b/src/dal/widgets.py @@ -10,7 +10,7 @@ try: from django.urls import reverse except ImportError: - from django.core.urlresolvers import reverse + from django.urls import reverse import six from django.utils.safestring import mark_safe diff --git a/src/dal_queryset_sequence/fields.py b/src/dal_queryset_sequence/fields.py index 944d32959..08daa872f 100644 --- a/src/dal_queryset_sequence/fields.py +++ b/src/dal_queryset_sequence/fields.py @@ -7,7 +7,7 @@ from django import forms from django.contrib.contenttypes.models import ContentType -from django.conf.urls import url +from django.urls import re_path from queryset_sequence import QuerySetSequence @@ -162,5 +162,5 @@ def as_url(self, form): AutoView = type('Autoview{}{}'.format(form.__name__, self.field_id), (self.view_obj,), {}) - return url(r'^{}_{}_autocomp$'.format(form.__name__, self.field_id), + return re_path(r'^{}_{}_autocomp$'.format(form.__name__, self.field_id), AutoView.as_view(queryset=self.queryset), name=url_name) diff --git a/src/dal_select2/__init__.py b/src/dal_select2/__init__.py index 5963b4997..a39af322a 100644 --- a/src/dal_select2/__init__.py +++ b/src/dal_select2/__init__.py @@ -1,3 +1,2 @@ """Select2 support for DAL.""" -default_app_config = 'dal_select2.apps.DefaultApp' diff --git a/src/dal_select2/views.py b/src/dal_select2/views.py index 510f28cc9..ec4b059ad 100644 --- a/src/dal_select2/views.py +++ b/src/dal_select2/views.py @@ -8,7 +8,7 @@ from django import http from django.core.exceptions import ImproperlyConfigured import six -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from django.views.generic.list import View diff --git a/src/dal_select2_queryset_sequence/fields.py b/src/dal_select2_queryset_sequence/fields.py index 1a10e59e3..2dc097a4d 100644 --- a/src/dal_select2_queryset_sequence/fields.py +++ b/src/dal_select2_queryset_sequence/fields.py @@ -1,4 +1,4 @@ -from django.conf.urls import url +from django.urls import re_path from dal_queryset_sequence.fields import QuerySetSequenceModelField @@ -44,5 +44,5 @@ def as_url(self, form): (Select2QuerySetSequenceAutoView,), {'model_choice': self.model_choice}) # send to the view the model and filter list - return url(r'^{}_{}_autocomp$'.format(form.__name__, self.field_id), + return re_path(r'^{}_{}_autocomp$'.format(form.__name__, self.field_id), AutoView.as_view(), name=url_name) From 4a1beb07b24563ce4de86e7450411e9a470028d3 Mon Sep 17 00:00:00 2001 From: raybittuiq Date: Fri, 15 Nov 2024 10:18:01 +0530 Subject: [PATCH 5/5] undo --- src/dal/test/case.py | 2 +- src/dal/views.py | 2 +- src/dal/widgets.py | 2 +- src/dal_select2/__init__.py | 1 + 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/dal/test/case.py b/src/dal/test/case.py index eb727ae3e..766e91487 100644 --- a/src/dal/test/case.py +++ b/src/dal/test/case.py @@ -10,7 +10,7 @@ try: from django.urls import reverse except ImportError: - from django.urls import reverse + from django.core.urlresolvers import reverse from django.utils import six from splinter import Browser diff --git a/src/dal/views.py b/src/dal/views.py index c916aea96..18d6b61e2 100644 --- a/src/dal/views.py +++ b/src/dal/views.py @@ -104,7 +104,7 @@ def create_object(self, text): def has_add_permission(self, request): """Return True if the user has the permission to add a model.""" if django.VERSION < (2, 0, 0): - auth = request.user.is_authenticated + auth = request.user.is_authenticated() else: auth = request.user.is_authenticated diff --git a/src/dal/widgets.py b/src/dal/widgets.py index ffc243942..d6976c3ce 100644 --- a/src/dal/widgets.py +++ b/src/dal/widgets.py @@ -10,7 +10,7 @@ try: from django.urls import reverse except ImportError: - from django.urls import reverse + from django.core.urlresolvers import reverse import six from django.utils.safestring import mark_safe diff --git a/src/dal_select2/__init__.py b/src/dal_select2/__init__.py index a39af322a..ffc95c1f2 100644 --- a/src/dal_select2/__init__.py +++ b/src/dal_select2/__init__.py @@ -1,2 +1,3 @@ """Select2 support for DAL.""" +default_app_config = 'dal_select2.apps.DefaultApp' \ No newline at end of file