Skip to content

Commit a93e76e

Browse files
committed
feat: upgrade to django 4
1 parent c2a1bb8 commit a93e76e

5 files changed

Lines changed: 25 additions & 28 deletions

File tree

config/settings.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838

3939
# If you set this to False, Django will not format dates, numbers and
4040
# calendars according to the current locale.
41-
USE_L10N = True
4241

4342
# If you set this to False, Django will not use timezone-aware datetimes.
4443
USE_TZ = True
@@ -62,7 +61,7 @@
6261

6362
DATABASES = {
6463
"default": {
65-
"ENGINE": "django.db.backends.postgresql_psycopg2",
64+
"ENGINE": "django.db.backends.postgresql",
6665
"NAME": "pokeapi_co_db",
6766
"USER": "root",
6867
"PASSWORD": "pokeapi",

config/urls.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
from django.conf.urls import include, url
1+
from django.urls import include, path
22
from pokemon_v2 import urls as pokemon_v2_urls
33

44
# pylint: disable=invalid-name
55

66
urlpatterns = [
7-
url(r"^", include(pokemon_v2_urls)),
7+
path("", include(pokemon_v2_urls)),
88
]

pokemon_v2/tests.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2683,7 +2683,7 @@ def test_item_api(self):
26832683
item_attribute_map.save()
26842684

26852685
response = self.client.get(
2686-
"{}/item/{}/".format(API_V2, item.pk), HTTP_HOST="testserver"
2686+
"{}/item/{}/".format(API_V2, item.pk), headers={"host": "testserver"}
26872687
)
26882688

26892689
# base params
@@ -4683,7 +4683,7 @@ def test_pokemon_species_api(self):
46834683

46844684
response = self.client.get(
46854685
"{}/pokemon-species/{}/".format(API_V2, pokemon_species.pk),
4686-
HTTP_HOST="testserver",
4686+
headers={"host": "testserver"}
46874687
)
46884688

46894689
self.assertEqual(response.status_code, status.HTTP_200_OK)
@@ -4947,7 +4947,7 @@ def test_pokemon_api(self):
49474947
max_level=36,
49484948
)
49494949
response = self.client.get(
4950-
"{}/pokemon/{}/".format(API_V2, pokemon.pk), HTTP_HOST="testserver"
4950+
"{}/pokemon/{}/".format(API_V2, pokemon.pk), headers={"host": "testserver"}
49514951
)
49524952

49534953
self.assertEqual(response.status_code, status.HTTP_200_OK)
@@ -5171,7 +5171,7 @@ def test_pokemon_api(self):
51715171

51725172
response = self.client.get(
51735173
"{}/pokemon/?q={}".format(API_V2, pokemon.name[:2]),
5174-
HTTP_HOST="testserver",
5174+
headers={"host": "testserver"}
51755175
)
51765176

51775177
self.assertEqual(response.status_code, status.HTTP_200_OK)
@@ -5197,7 +5197,7 @@ def test_pokemon_form_api(self):
51975197

51985198
response = self.client.get(
51995199
"{}/pokemon-form/{}/".format(API_V2, pokemon_form.pk),
5200-
HTTP_HOST="testserver",
5200+
headers={"host": "testserver"}
52015201
)
52025202

52035203
self.assertEqual(response.status_code, status.HTTP_200_OK)
@@ -5767,13 +5767,13 @@ def test_case_insensitive_api(self):
57675767

57685768
# Test lowercase
57695769
lowercase_response = self.client.get(
5770-
"{}/pokemon/{}/".format(API_V2, lowercase_name), HTTP_HOST="testserver"
5770+
"{}/pokemon/{}/".format(API_V2, lowercase_name), headers={"host": "testserver"}
57715771
)
57725772
self.assertEqual(lowercase_response.status_code, status.HTTP_200_OK)
57735773

57745774
# Test uppercase
57755775
uppercase_response = self.client.get(
5776-
"{}/pokemon/{}/".format(API_V2, uppercase_name), HTTP_HOST="testserver"
5776+
"{}/pokemon/{}/".format(API_V2, uppercase_name), headers={"host": "testserver"}
57775777
)
57785778
self.assertEqual(uppercase_response.status_code, status.HTTP_200_OK)
57795779

@@ -5787,12 +5787,12 @@ def test_case_insensitive_api(self):
57875787
uppercase_name = language.name.upper()
57885788

57895789
lowercase_response = self.client.get(
5790-
"{}/language/{}/".format(API_V2, lowercase_name), HTTP_HOST="testserver"
5790+
"{}/language/{}/".format(API_V2, lowercase_name), headers={"host": "testserver"}
57915791
)
57925792
self.assertEqual(lowercase_response.status_code, status.HTTP_200_OK)
57935793

57945794
uppercase_response = self.client.get(
5795-
"{}/language/{}/".format(API_V2, uppercase_name), HTTP_HOST="testserver"
5795+
"{}/language/{}/".format(API_V2, uppercase_name), headers={"host": "testserver"}
57965796
)
57975797
self.assertEqual(uppercase_response.status_code, status.HTTP_200_OK)
57985798

pokemon_v2/urls.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from django.conf.urls import include, url
1+
from django.urls import include, path, re_path
22

33
#####################################
44
#
@@ -70,8 +70,8 @@
7070
###########################
7171

7272
urlpatterns = [
73-
url(r"^api/v2/", include(router.urls)),
74-
url(
73+
path("api/v2/", include(router.urls)),
74+
re_path(
7575
r"^api/v2/pokemon/(?P<pokemon_id>\d+)/encounters",
7676
PokemonEncounterView.as_view(),
7777
name="pokemon_encounters",

requirements.txt

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
Django==3.2.25
1+
Django==4.2.27
22
Unipath==1.1
3-
coverage==4.5.4
4-
django-cors-headers==3.14.0
5-
django-discover-runner==1.0
6-
django-redis==4.12.1
7-
django-cachalot==2.4.5
8-
djangorestframework==3.14.0
3+
coverage==7.13.1
4+
django-cors-headers==4.9.0
5+
django-redis==6.0.0
6+
django-cachalot==2.8.0
7+
djangorestframework==3.16.1
98
gunicorn==23.0.0
10-
mimeparse==0.1.3
11-
psycopg2-binary==2.9.10
12-
python-dateutil==2.8.2
13-
python-mimeparse==1.6.0
14-
drf-spectacular==0.28.0
9+
psycopg==3.3.2
10+
python-dateutil==2.9.0
11+
python-mimeparse==2.0.0
12+
drf-spectacular==0.29.0
1513
legacy-cgi; python_version >= '3.13'

0 commit comments

Comments
 (0)