Skip to content

Commit d00f8fb

Browse files
authored
Update Django (#10479)
* Format with `ruff`. * Bump all dependencies. Fix legacy regex url paths. * Bump Python to 3.13. * Swap `orjson` in for `ujson`. * Fix incorrect webserver classification from `Meinheld` to `Gunicorn`. * Use `StreamHttpResponse` for plaintext endpoint. * Change socketify to use Python 3.13. * Try pypi-3.11-slim. * Add dependencies for django-socketify-wsgi-pypy. * Remove django-socketify-wsgi-pypy. * Remove `socketify-wsgi-pypy` test since it consistently fails.
1 parent a8c8c6c commit d00f8fb

File tree

13 files changed

+144
-200
lines changed

13 files changed

+144
-200
lines changed
Lines changed: 69 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,72 @@
11
{
22
"framework": "django",
3-
"tests": [{
4-
"default": {
5-
"plaintext_url" : "/plaintext",
6-
"json_url": "/json",
7-
"db_url": "/db",
8-
"query_url": "/dbs?queries=",
9-
"fortune_url": "/fortunes",
10-
"update_url": "/update?queries=",
11-
"port": 8080,
12-
"approach": "Realistic",
13-
"classification": "Fullstack",
14-
"database": "MySQL",
15-
"framework": "django",
16-
"language": "Python",
17-
"flavor": "Python3",
18-
"orm": "Full",
19-
"platform": "WSGI",
20-
"webserver": "Gunicorn",
21-
"os": "Linux",
22-
"database_os": "Linux",
23-
"display_name": "Django",
24-
"notes": "",
25-
"versus": "wsgi",
26-
"tags": [ ]
27-
},
28-
"socketify-wsgi": {
29-
"plaintext_url" : "/plaintext",
30-
"json_url": "/json",
31-
"port": 8080,
32-
"approach": "Realistic",
33-
"classification": "Fullstack",
34-
"database": "None",
35-
"framework": "django",
36-
"language": "Python",
37-
"flavor": "Python3",
38-
"orm": "Raw",
39-
"platform": "WSGI",
40-
"webserver": "Socketify.py",
41-
"os": "Linux",
42-
"database_os": "Linux",
43-
"display_name": "Django [Socketify.py WSGI]",
44-
"notes": "",
45-
"versus": "wsgi"
46-
},
47-
"socketify-wsgi-pypy": {
48-
"plaintext_url" : "/plaintext",
49-
"json_url": "/json",
50-
"port": 8080,
51-
"approach": "Realistic",
52-
"classification": "Fullstack",
53-
"database": "None",
54-
"framework": "django",
55-
"language": "Python",
56-
"flavor": "PyPy3",
57-
"orm": "Raw",
58-
"platform": "WSGI",
59-
"webserver": "Socketify.py",
60-
"os": "Linux",
61-
"database_os": "Linux",
62-
"display_name": "Django [Socketify.py WSGI PyPy3]",
63-
"notes": "",
64-
"versus": "wsgi"
65-
},
66-
"postgresql": {
67-
"db_url": "/db",
68-
"query_url": "/dbs?queries=",
69-
"fortune_url": "/fortunes",
70-
"update_url": "/update?queries=",
71-
"port": 8080,
72-
"approach": "Realistic",
73-
"classification": "Fullstack",
74-
"database": "Postgres",
75-
"framework": "django",
76-
"language": "Python",
77-
"flavor": "Python3",
78-
"orm": "Full",
79-
"platform": "WSGI",
80-
"webserver": "Gunicorn",
81-
"os": "Linux",
82-
"database_os": "Linux",
83-
"display_name": "Django [Postgres]",
84-
"notes": "",
85-
"versus": "wsgi",
86-
"tags": [ ]
3+
"tests": [
4+
{
5+
"default": {
6+
"plaintext_url": "/plaintext",
7+
"json_url": "/json",
8+
"db_url": "/db",
9+
"query_url": "/dbs?queries=",
10+
"fortune_url": "/fortunes",
11+
"update_url": "/update?queries=",
12+
"port": 8080,
13+
"approach": "Realistic",
14+
"classification": "Fullstack",
15+
"database": "MySQL",
16+
"framework": "django",
17+
"language": "Python",
18+
"flavor": "Python3",
19+
"orm": "Full",
20+
"platform": "WSGI",
21+
"webserver": "Gunicorn",
22+
"os": "Linux",
23+
"database_os": "Linux",
24+
"display_name": "Django",
25+
"notes": "",
26+
"versus": "wsgi",
27+
"tags": []
28+
},
29+
"socketify-wsgi": {
30+
"plaintext_url": "/plaintext",
31+
"json_url": "/json",
32+
"port": 8080,
33+
"approach": "Realistic",
34+
"classification": "Fullstack",
35+
"database": "None",
36+
"framework": "django",
37+
"language": "Python",
38+
"flavor": "Python3",
39+
"orm": "Raw",
40+
"platform": "WSGI",
41+
"webserver": "Socketify.py",
42+
"os": "Linux",
43+
"database_os": "Linux",
44+
"display_name": "Django [Socketify.py WSGI]",
45+
"notes": "",
46+
"versus": "wsgi"
47+
},
48+
"postgresql": {
49+
"db_url": "/db",
50+
"query_url": "/dbs?queries=",
51+
"fortune_url": "/fortunes",
52+
"update_url": "/update?queries=",
53+
"port": 8080,
54+
"approach": "Realistic",
55+
"classification": "Fullstack",
56+
"database": "Postgres",
57+
"framework": "django",
58+
"language": "Python",
59+
"flavor": "Python3",
60+
"orm": "Full",
61+
"platform": "WSGI",
62+
"webserver": "Gunicorn",
63+
"os": "Linux",
64+
"database_os": "Linux",
65+
"display_name": "Django [Postgres]",
66+
"notes": "",
67+
"versus": "wsgi",
68+
"tags": []
69+
}
8770
}
88-
}]
89-
}
71+
]
72+
}

frameworks/Python/django/config.toml

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ database_os = "Linux"
1515
os = "Linux"
1616
orm = "Full"
1717
platform = "WSGI"
18-
webserver = "Meinheld"
18+
webserver = "Gunicorn"
1919
versus = "wsgi"
2020

2121
[socketify-wsgi]
@@ -31,19 +31,6 @@ platform = "WSGI"
3131
webserver = "Socketify.py"
3232
versus = "wsgi"
3333

34-
[socketify-wsgi-pypy]
35-
urls.plaintext = "/plaintext"
36-
urls.json = "/json"
37-
approach = "Realistic"
38-
classification = "Fullstack"
39-
database = "MySQL"
40-
database_os = "Linux"
41-
os = "Linux"
42-
orm = "Raw"
43-
platform = "WSGI"
44-
webserver = "Socketify.py"
45-
versus = "wsgi"
46-
4734
[postgresql]
4835
urls.db = "/db"
4936
urls.query = "/dbs?queries="
@@ -56,5 +43,5 @@ database_os = "Linux"
5643
os = "Linux"
5744
orm = "Full"
5845
platform = "WSGI"
59-
webserver = "Meinheld"
46+
webserver = "Gunicorn"
6047
versus = "wsgi"

frameworks/Python/django/django-postgresql.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.12-bullseye
1+
FROM python:3.13-bullseye
22

33
ADD ./ /django
44

frameworks/Python/django/django-socketify-wsgi-pypy.dockerfile

Lines changed: 0 additions & 11 deletions
This file was deleted.

frameworks/Python/django/django-socketify-wsgi.dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
FROM python:3.10-bullseye
1+
FROM python:3.13-bullseye
22

33
ADD ./ /django
44

55
WORKDIR /django
6-
RUN apt-get update; apt-get install libuv1 -y
7-
RUN pip install -r /django/requirements-socketify.txt
6+
7+
RUN apt-get update && \
8+
apt-get install gcc g++ make libuv1 zlib1g -y && \
9+
pip install -r /django/requirements-socketify.txt
810

911
EXPOSE 8080
1012

frameworks/Python/django/django.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.12-bullseye
1+
FROM python:3.13-bullseye
22

33
ADD ./ /django
44

frameworks/Python/django/hello/hello/settings.py

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,66 +2,66 @@
22

33
DEBUG = False
44

5-
SECRET_KEY = '_7mb6#v4yf@qhc(r(zbyh&z_iby-na*7wz&-v6pohsul-d#y5f'
5+
SECRET_KEY = "_7mb6#v4yf@qhc(r(zbyh&z_iby-na*7wz&-v6pohsul-d#y5f"
66
ADMINS = ()
77

88
MANAGERS = ADMINS
99

10-
_django_db = os.getenv('DJANGO_DB', "")
10+
_django_db = os.getenv("DJANGO_DB", "")
1111

1212
DATABASES = {
13-
'default': {
14-
'ENGINE': 'django.db.backends.' + _django_db, # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
15-
'NAME': 'hello_world', # Or path to database file if using sqlite3.
16-
'USER': 'benchmarkdbuser', # Not used with sqlite3.
17-
'PASSWORD': 'benchmarkdbpass', # Not used with sqlite3.
18-
'HOST': 'tfb-database', # Set to empty string for localhost. Not used with sqlite3.
19-
'PORT': '', # Set to empty string for default. Not used with sqlite3.
20-
'CONN_MAX_AGE': 30,
13+
"default": {
14+
"ENGINE": "django.db.backends."
15+
+ _django_db, # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
16+
"NAME": "hello_world", # Or path to database file if using sqlite3.
17+
"USER": "benchmarkdbuser", # Not used with sqlite3.
18+
"PASSWORD": "benchmarkdbpass", # Not used with sqlite3.
19+
"HOST": "tfb-database", # Set to empty string for localhost. Not used with sqlite3.
20+
"PORT": "", # Set to empty string for default. Not used with sqlite3.
21+
"CONN_MAX_AGE": 30,
2122
}
2223
}
2324

2425
if not _django_db:
25-
DATABASES = { }
26+
DATABASES = {}
2627

27-
TIME_ZONE = 'America/Chicago'
28-
LANGUAGE_CODE = 'en-us'
28+
TIME_ZONE = "America/Chicago"
29+
LANGUAGE_CODE = "en-us"
2930
USE_I18N = False
3031
USE_L10N = False
3132
USE_TZ = False
3233

33-
MEDIA_ROOT = ''
34-
MEDIA_URL = ''
35-
STATIC_ROOT = ''
36-
STATIC_URL = '/static/'
34+
MEDIA_ROOT = ""
35+
MEDIA_URL = ""
36+
STATIC_ROOT = ""
37+
STATIC_URL = "/static/"
3738
STATICFILES_DIRS = ()
3839
STATICFILES_FINDERS = ()
3940
MIDDLEWARE = ()
4041

41-
ROOT_URLCONF = 'hello.urls'
42-
WSGI_APPLICATION = 'hello.wsgi.application'
42+
ROOT_URLCONF = "hello.urls"
43+
WSGI_APPLICATION = "hello.wsgi.application"
4344

4445
TEMPLATES = [
4546
{
46-
'BACKEND': 'django.template.backends.django.DjangoTemplates',
47-
'DIRS': [],
48-
'APP_DIRS': True,
49-
'OPTIONS': {},
47+
"BACKEND": "django.template.backends.django.DjangoTemplates",
48+
"DIRS": [],
49+
"APP_DIRS": True,
50+
"OPTIONS": {},
5051
},
5152
]
5253

5354
INSTALLED_APPS = (
54-
'django.contrib.contenttypes',
55-
'django.contrib.sessions',
56-
'world',
55+
"django.contrib.contenttypes",
56+
"django.contrib.sessions",
57+
"world",
5758
)
5859

5960
LOGGING = {
60-
'version': 1,
61-
'disable_existing_loggers': True,
62-
'handlers': {},
63-
'loggers': {},
64-
61+
"version": 1,
62+
"disable_existing_loggers": True,
63+
"handlers": {},
64+
"loggers": {},
6565
}
6666

67-
ALLOWED_HOSTS = ['*']
67+
ALLOWED_HOSTS = ["*"]
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
from django.conf.urls import url
1+
from django.urls import path
22
from world.views import plaintext, json, db, dbs, fortunes, update
33

44
urlpatterns = [
5-
url(r'^plaintext$', plaintext),
6-
url(r'^json$', json),
7-
url(r'^db$', db),
8-
url(r'^dbs$', dbs),
9-
url(r'^fortunes$', fortunes),
10-
url(r'^update$', update),
5+
path("plaintext", plaintext),
6+
path("json", json),
7+
path("db", db),
8+
path("dbs", dbs),
9+
path("fortunes", fortunes),
10+
path("update", update),
1111
]
Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,7 @@
1-
"""
2-
WSGI config for hello project.
3-
4-
This module contains the WSGI application used by Django's development server
5-
and any production WSGI deployments. It should expose a module-level variable
6-
named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover
7-
this application via the ``WSGI_APPLICATION`` setting.
8-
9-
Usually you will have the standard Django WSGI application here, but it also
10-
might make sense to replace the whole Django WSGI application with a custom one
11-
that later delegates to the Django one. For example, you could introduce WSGI
12-
middleware here, or combine a Django application with an application of another
13-
framework.
14-
15-
"""
161
import os
172

183
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "hello.settings")
194

205
from django.core.wsgi import get_wsgi_application
6+
217
application = get_wsgi_application()

frameworks/Python/django/hello/world/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ class World(models.Model):
55
randomnumber = models.IntegerField()
66

77
class Meta:
8-
db_table = 'world'
8+
db_table = "world"
99

1010

1111
class Fortune(models.Model):
1212
message = models.CharField(max_length=65535)
1313

1414
class Meta:
15-
db_table = 'fortune'
15+
db_table = "fortune"

0 commit comments

Comments
 (0)