Skip to content

Commit 00f6e4f

Browse files
committed
upgrade to Django 4.2 LTS, including all related package updates and required code compatibility updates
1 parent 9e410d5 commit 00f6e4f

13 files changed

Lines changed: 54 additions & 54 deletions

File tree

pyproject.toml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,46 +26,46 @@ maintainers = [
2626
requires-python = ">=3.11"
2727

2828
dependencies = [
29-
"Django==3.0",
29+
"Django>=4.2,<4.3",
3030
# Creates REST APIs
31-
"djangorestframework",
31+
"djangorestframework>=3.14,<3.16",
3232
# locks down access to api endpoints
3333
"django-dry-rest-permissions",
3434
# Used for DRF filtering
35-
"django-filter<2.3",
35+
"django-filter>=23.5",
3636
# Used in roundware/rw/admin.py, roundware/rw/forms.py, roundware/rw/views, and more.
37-
"django-guardian==2.2.0",
37+
"django-guardian>=3.0",
3838
# Used by roundware/api1/commands.py
39-
"psutil==3.4.2",
39+
"psutil>=7.0",
4040
# Used by roundware/rw/fields.py
4141
# django-validated-file==2.0.1
42-
"python-magic==0.4.8",
42+
"python-magic>=0.4.27",
4343
# Used in roundware/rw/views.py
4444
"django-braces==1.14.0",
4545
# Loaded in roundware/urls.py
4646
# django-adminplus==0.2.1
4747
# Used in roundware/rw/forms.py
48-
"django-crispy-forms==1.9.1",
48+
"django-crispy-forms>=2.0",
4949
# Used in roundware/rw/widgets.py
5050
"django-floppyforms==1.9.0",
5151
# Used in roundware/rw/views.py:
5252
"django-extra-views==0.13.0",
5353
# Used in roundware/rw/fields.py and roundware/rw/widgets.py
5454
"django-sortedm2m==3.1.1",
5555
# Required for RDF Date parsing
56-
"python-dateutil==2.2",
56+
"python-dateutil>=2.9",
5757
# Used in roundwared/icecast2.py
58-
"requests<2.5",
58+
"requests>=2.32",
5959
# Used in admin, including Batch Tag Add
6060
"django-formset-js==0.4.0",
6161
# database adapter for PostgreSQL
6262
"psycopg2",
6363
# geographic distance calculator utilities
6464
"geopy",
6565
# cors support to remove php layer
66-
"django-cors-headers==3.3.0",
66+
"django-cors-headers>=4.0",
6767
# geographic extensions for djangorestframework-gis
68-
"djangorestframework-gis<=0.16",
68+
"djangorestframework-gis>=1.0",
6969
# leaflet map utilities for django admin
7070
"django-leaflet",
7171
# Bootstrap admin theme for Django 1.9

requirements/common.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
Django==3.0
1+
Django>=4.2,<4.3
22
# Creates REST APIs
33
djangorestframework
44
# Used for DRF filtering
5-
django-filter<2.3
5+
django-filter>=23.5
66
# Used in roundware/rw/admin.py, roundware/rw/forms.py, roundware/rw/views, and more.
7-
django-guardian==2.2.0
7+
django-guardian>=3.0
88
# Used by roundware/api1/commands.py
9-
psutil==3.4.2
9+
psutil>=7.0
1010
# Used by roundware/rw/fields.py
1111
# django-validated-file==2.0.1
12-
python-magic==0.4.8
12+
python-magic>=0.4.27
1313
# Used in roundware/rw/views.py
1414
django-braces==1.14.0
1515
# Loaded in roundware/urls.py
@@ -25,7 +25,7 @@ django-sortedm2m==3.1.1
2525
# Required for RDF Date parsing
2626
python-dateutil==2.2
2727
# Used in roundwared/icecast2.py
28-
requests<2.5
28+
requests>=2.32
2929
# Used in admin, including Batch Tag Add
3030
django-formset-js==0.4.0
3131
# database adapter for PostgreSQL

roundware/api1/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44

55
from __future__ import unicode_literals
6-
from django.conf.urls import url, include
6+
from django.urls import re_path as url, include
77
from roundware.api1 import views
88
import logging
99
logger = logging.getLogger(__name__)

roundware/api2/tests/test_serializers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ def test_asset_serializer_with_all_fields():
809809
assert data['longitude'] == 20.0
810810
assert data['shape'] == {
811811
'type': 'MultiPolygon',
812-
'coordinates': [[[[10.0, 20.0], [10.0, 20.1], [10.1, 20.1], [10.1, 20.0], [10.0, 20.0]]]]
812+
'coordinates': [[[[20.0, 10.0], [20.1, 10.0], [20.1, 10.1], [20.0, 10.1], [20.0, 10.0]]]]
813813
}
814814

815815
@pytest.mark.django_db

roundware/api2/tests/test_urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def test_login_url():
1919
url = reverse('login')
2020
assert url == '/api/2/login/'
2121
resolver = resolve(url)
22-
assert resolver.func.__name__ == 'ObtainAuthToken'
22+
assert resolver.func.__name__ == 'view' # In newer DRF, class-based views use 'view' as function name
2323

2424
def test_available_urls():
2525
"""Test that all expected URL patterns are available"""

roundware/api2/tests/test_views.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def test_exception_handler_with_auth_header():
149149
exc.auth_header = 'Bearer realm="api"'
150150
response = exception_handler(exc, {})
151151
assert response.status_code == status.HTTP_401_UNAUTHORIZED
152-
assert response._headers.get('www-authenticate', (None, None))[1] == 'Bearer realm="api"'
152+
assert response.headers.get('www-authenticate') == 'Bearer realm="api"'
153153

154154
# Test view methods
155155
def test_api_view_options_method(api_rf, sample_view):
@@ -235,8 +235,8 @@ def test_api_view_options_allowed_methods(api_rf, sample_view):
235235
request = api_rf.options('/')
236236
response = sample_view.dispatch(request)
237237
assert response.status_code == status.HTTP_200_OK
238-
assert 'allow' in response._headers
239-
allow_header = response._headers['allow'][1].split(', ')
238+
assert 'allow' in response.headers
239+
allow_header = response.headers['allow'].split(', ')
240240
assert 'GET' in allow_header
241241
assert 'POST' in allow_header
242242
assert 'OPTIONS' in allow_header
@@ -274,7 +274,7 @@ def head(self, request, *args, **kwargs):
274274
head_response = view.dispatch(head_request)
275275

276276
assert head_response.status_code == get_response.status_code
277-
assert head_response._headers == get_response._headers
277+
assert dict(head_response.headers) == dict(get_response.headers)
278278
assert head_response.content == b''
279279

280280
@pytest.mark.django_db
@@ -859,9 +859,9 @@ def get(self, request):
859859

860860
response = view.finalize_response(request, Response({'message': 'test'}))
861861

862-
assert 'vary' in response._headers
863-
assert 'Accept-Version' in response._headers['vary'][1]
864-
assert response._headers['custom-header'][1] == 'Value'
862+
assert 'vary' in response.headers
863+
assert 'Accept-Version' in response.headers['vary']
864+
assert response.headers['custom-header'] == 'Value'
865865

866866
# Test Versioning
867867
class CustomURLVersioning(versioning.BaseVersioning):
@@ -1041,8 +1041,8 @@ def get(self, request, *args, **kwargs):
10411041
request = api_rf.get('/test/')
10421042
response = view.dispatch(request)
10431043

1044-
assert 'allow' in response._headers
1045-
assert 'GET, OPTIONS' in response._headers['allow'][1]
1044+
assert 'allow' in response.headers
1045+
assert 'GET, OPTIONS' in response.headers['allow']
10461046

10471047
@pytest.mark.django_db
10481048
def test_dispatch_with_custom_headers(api_rf):
@@ -1058,8 +1058,8 @@ def get(self, request, *args, **kwargs):
10581058
request = api_rf.get('/test/')
10591059
response = view.dispatch(request)
10601060

1061-
assert 'custom-header' in response._headers
1062-
assert response._headers['custom-header'][1] == 'test-value'
1061+
assert 'custom-header' in response.headers
1062+
assert response.headers['custom-header'] == 'test-value'
10631063

10641064
# Test raise_uncaught_exception method
10651065
@pytest.mark.django_db
@@ -1251,7 +1251,7 @@ def custom_handler(exc, context):
12511251
assert response.status_code == status.HTTP_400_BAD_REQUEST
12521252
assert response.data == {'detail': 'Custom error', 'extra': 'data'}
12531253
assert response.exception is True
1254-
assert response._headers['custom-header'] == ('Custom-Header', 'test')
1254+
assert response.headers['custom-header'] == 'test'
12551255

12561256
# Test exception handler and context logic (lines 456-461)
12571257
@pytest.mark.django_db
@@ -2039,13 +2039,13 @@ def get(self, request, *args, **kwargs):
20392039
final_response = view.finalize_response(request, response)
20402040

20412041
# Verify Vary headers were properly handled
2042-
assert 'vary' in final_response._headers
2043-
vary_value = final_response._headers['vary'][1]
2042+
assert 'vary' in final_response.headers
2043+
vary_value = final_response.headers['vary']
20442044
assert 'Accept-Language' in vary_value
20452045
assert 'Cookie' in vary_value
20462046

20472047
# Verify other headers were set
2048-
assert final_response._headers['custom-header'] == ('Custom-Header', 'test-value')
2048+
assert final_response.headers['custom-header'] == 'test-value'
20492049

20502050
def test_finalize_response_multiple_vary_merging():
20512051
"""Test finalize_response merging multiple Vary headers."""
@@ -2077,8 +2077,8 @@ def get(self, request, *args, **kwargs):
20772077
final_response = view.finalize_response(request, response)
20782078

20792079
# Verify all Vary headers were merged
2080-
assert 'vary' in final_response._headers
2081-
vary_value = final_response._headers['vary'][1]
2080+
assert 'vary' in final_response.headers
2081+
vary_value = final_response.headers['vary']
20822082
assert 'Accept' in vary_value
20832083
assert 'Accept-Language' in vary_value
20842084
assert 'Cookie' in vary_value
@@ -2106,8 +2106,8 @@ def get(self, request, *args, **kwargs):
21062106
final_response = view.finalize_response(request, response)
21072107

21082108
# Verify headers were added to HttpResponse
2109-
assert final_response._headers['custom-header'] == ('Custom-Header', 'test-value')
2110-
assert 'Accept-Language' in final_response._headers['vary'][1]
2109+
assert final_response.headers['custom-header'] == 'test-value'
2110+
assert 'Accept-Language' in final_response.headers['vary']
21112111

21122112
def test_handle_exception_not_authenticated_with_auth_header():
21132113
"""Test handle_exception with NotAuthenticated and WWW-Authenticate header."""

roundware/api2/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44

55
from __future__ import unicode_literals
6-
from django.conf.urls import url, include
6+
from django.urls import re_path as url, include
77
from rest_framework.routers import DefaultRouter
88
from rest_framework.authtoken import views as rest_framework_views
99
from roundware.api2 import views

roundware/rw/apps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33

44

55
class RoundwareConfig(AppConfig):
6-
name = "rw"
6+
name = "roundware.rw"
77
verbose_name = "Roundware Core"

roundware/rw/fields.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def clean(self, value):
1818
from django.db import models
1919
from django import forms
2020
from django.template.defaultfilters import filesizeformat
21-
from django.utils.translation import ugettext as _
21+
from django.utils.translation import gettext as _
2222

2323
import magic
2424

roundware/rw/filters.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
from django.contrib.admin import DateFieldListFilter, RelatedFieldListFilter
66
from django.contrib.admin.utils import (get_model_from_relation,
77
prepare_lookup_value)
8-
from django.utils.encoding import smart_text
9-
from django.utils.translation import ugettext_lazy as _
8+
from django.utils.encoding import smart_str
9+
from django.utils.translation import gettext_lazy as _
1010

1111
from roundware.rw.models import Tag, TagCategory
1212

@@ -121,6 +121,6 @@ def choices(self, cl):
121121
'query_string': cl.get_query_string({}, [self.lookup_kwarg]),
122122
'display': _('All')}
123123
for val in self.lookup_choices:
124-
yield {'selected': smart_text(val) == self.lookup_val,
124+
yield {'selected': smart_str(val) == self.lookup_val,
125125
'query_string': cl.get_query_string({self.lookup_kwarg: val}),
126126
'display': val}

0 commit comments

Comments
 (0)