diff --git a/bin/smsd.py b/bin/smsd.py index 709bb8d26c..2c82a33331 100755 --- a/bin/smsd.py +++ b/bin/smsd.py @@ -29,7 +29,7 @@ import sys import time -from nav.compatibility import smart_str +from django.utils.encoding import smart_str import nav.config import nav.daemon diff --git a/python/nav/auditlog/models.py b/python/nav/auditlog/models.py index 687daf99c9..4246d6cc27 100644 --- a/python/nav/auditlog/models.py +++ b/python/nav/auditlog/models.py @@ -18,7 +18,7 @@ from __future__ import unicode_literals, absolute_import import logging -from nav.compatibility import force_str +from django.utils.encoding import force_str from django.db import models from django.utils.timezone import now as utcnow diff --git a/python/nav/auditlog/utils.py b/python/nav/auditlog/utils.py index 50fa700a65..d6f0c34c9c 100644 --- a/python/nav/auditlog/utils.py +++ b/python/nav/auditlog/utils.py @@ -16,7 +16,7 @@ # from __future__ import unicode_literals -from nav.compatibility import force_str +from django.utils.encoding import force_str from django.db.models import Q from . import find_modelname diff --git a/python/nav/compatibility.py b/python/nav/compatibility.py index e5907b0473..07ca52d024 100644 --- a/python/nav/compatibility.py +++ b/python/nav/compatibility.py @@ -1,19 +1,3 @@ -# Django 2.2 has only *_text, Django 3.2 has both *_text and *_str, -# Django 4.0 has only *_str. These are imported so many places that -# it is better to do it once, hence this file - -# When no longer supporting 2.2: -# s/nav.compatibility \(import \w+_str\)/django.utils.encoding \1/ -try: - from django.utils.encoding import force_str -except ImportError: - from django.utils.encoding import force_text as force_str - -try: - from django.utils.encoding import smart_str -except ImportError: - from django.utils.encoding import smart_text as smart_str - # lru_cache isn't used that much but one application of sed is faster # than changing a block into a line three times. diff --git a/python/nav/mibs/cisco_process_mib.py b/python/nav/mibs/cisco_process_mib.py index 432dae5c6c..d2748ce561 100644 --- a/python/nav/mibs/cisco_process_mib.py +++ b/python/nav/mibs/cisco_process_mib.py @@ -16,7 +16,7 @@ # from twisted.internet import defer -from nav.compatibility import smart_str +from django.utils.encoding import smart_str from nav.smidumps import get_mib from nav.mibs import mibretriever diff --git a/python/nav/mibs/itw_mib.py b/python/nav/mibs/itw_mib.py index c7e87b2558..13cb51b715 100644 --- a/python/nav/mibs/itw_mib.py +++ b/python/nav/mibs/itw_mib.py @@ -22,7 +22,7 @@ Uses the vendor-specifica IT-WATCHDOGS-MIB to detect and collect sensor-information. """ -from nav.compatibility import smart_str +from django.utils.encoding import smart_str from twisted.internet import defer from nav.mibs import reduce_index diff --git a/python/nav/web/api/v1/alert_serializers.py b/python/nav/web/api/v1/alert_serializers.py index cc6e616e89..c1e7d42ab2 100644 --- a/python/nav/web/api/v1/alert_serializers.py +++ b/python/nav/web/api/v1/alert_serializers.py @@ -18,7 +18,7 @@ from django.core.exceptions import ObjectDoesNotExist from django.template.defaultfilters import urlize from django.urls import reverse -from nav.compatibility import force_str +from django.utils.encoding import force_str from django.utils.html import strip_tags from rest_framework import serializers diff --git a/python/nav/web/useradmin/forms.py b/python/nav/web/useradmin/forms.py index 7d6546f718..80c178d634 100644 --- a/python/nav/web/useradmin/forms.py +++ b/python/nav/web/useradmin/forms.py @@ -19,7 +19,7 @@ from datetime import date, timedelta from django import forms -from nav.compatibility import force_str +from django.utils.encoding import force_str from crispy_forms.helper import FormHelper from crispy_forms_foundation.layout import ( diff --git a/tests/integration/api_test.py b/tests/integration/api_test.py index 44faf5b483..f1226ced01 100644 --- a/tests/integration/api_test.py +++ b/tests/integration/api_test.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- from __future__ import print_function -from nav.compatibility import force_str +from django.utils.encoding import force_str from datetime import datetime, timedelta import json diff --git a/tests/integration/seeddb_test.py b/tests/integration/seeddb_test.py index 0a11c10811..bfd6b6bb97 100644 --- a/tests/integration/seeddb_test.py +++ b/tests/integration/seeddb_test.py @@ -5,7 +5,7 @@ from django.test.client import RequestFactory from mock import MagicMock -from nav.compatibility import smart_str +from django.utils.encoding import smart_str from nav.models.manage import Netbox, Room from nav.web.seeddb.page.netbox.edit import netbox_edit, log_netbox_change from nav.web.seeddb.utils.delete import dependencies diff --git a/tests/integration/web/alertprofiles_test.py b/tests/integration/web/alertprofiles_test.py index cc9d72850c..9ef91afcf3 100644 --- a/tests/integration/web/alertprofiles_test.py +++ b/tests/integration/web/alertprofiles_test.py @@ -7,7 +7,7 @@ from django.test.client import RequestFactory from django.urls import reverse -from nav.compatibility import smart_str +from django.utils.encoding import smart_str from nav.models.profiles import ( AlertAddress, AlertPreference, diff --git a/tests/integration/web/devicehistory_test.py b/tests/integration/web/devicehistory_test.py index 9c13932030..748661fc36 100644 --- a/tests/integration/web/devicehistory_test.py +++ b/tests/integration/web/devicehistory_test.py @@ -4,7 +4,7 @@ from nav.models.event import EventQueue, EventQueueVar from django.urls import reverse -from nav.compatibility import smart_str +from django.utils.encoding import smart_str def test_post_device_error_should_succeed(client, localhost): diff --git a/tests/integration/web/ipdevinfo_test.py b/tests/integration/web/ipdevinfo_test.py index a3c6b86570..b04d25129c 100644 --- a/tests/integration/web/ipdevinfo_test.py +++ b/tests/integration/web/ipdevinfo_test.py @@ -2,7 +2,7 @@ from __future__ import print_function from django.urls import reverse -from nav.compatibility import smart_str +from django.utils.encoding import smart_str from nav.models.manage import Netbox, Module, Interface, Device, NetboxProfile from nav.web.ipdevinfo.utils import get_module_view diff --git a/tests/integration/web/maintenance/views_test.py b/tests/integration/web/maintenance/views_test.py index 1987c62c2d..608fbe7e8e 100644 --- a/tests/integration/web/maintenance/views_test.py +++ b/tests/integration/web/maintenance/views_test.py @@ -18,7 +18,7 @@ import pytest from django.urls import reverse -from nav.compatibility import smart_str +from django.utils.encoding import smart_str from nav.models.manage import Netbox from nav.models.msgmaint import MaintenanceTask diff --git a/tests/integration/web/netboxtype_test.py b/tests/integration/web/netboxtype_test.py index 8375fc4f7d..616dd4cf65 100644 --- a/tests/integration/web/netboxtype_test.py +++ b/tests/integration/web/netboxtype_test.py @@ -5,7 +5,7 @@ from nav.web.seeddb.forms import SEPARATOR from django.urls import reverse -from nav.compatibility import smart_str +from django.utils.encoding import smart_str def test_post_netboxtype_with_sysobjectid_without_leading_period_should_succeed(client): diff --git a/tests/integration/web/prefixviewset_test.py b/tests/integration/web/prefixviewset_test.py index 2be61de0f5..ddc93241b0 100644 --- a/tests/integration/web/prefixviewset_test.py +++ b/tests/integration/web/prefixviewset_test.py @@ -2,7 +2,7 @@ import pytest from nav.models.manage import Prefix, Vlan, NetType -from nav.compatibility import force_str +from django.utils.encoding import force_str from nav.web.api.v1.views import get_endpoints ENDPOINTS = {name: force_str(url) for name, url in get_endpoints().items()} diff --git a/tests/integration/web/webfront_test.py b/tests/integration/web/webfront_test.py index d64684af73..fec53f095f 100644 --- a/tests/integration/web/webfront_test.py +++ b/tests/integration/web/webfront_test.py @@ -1,7 +1,7 @@ from mock import Mock from django.urls import reverse -from nav.compatibility import smart_str +from django.utils.encoding import smart_str from nav.models.profiles import AccountDashboard from nav.web.webfront.utils import tool_list