diff --git a/frameworks/Python/django/benchmark_config.json b/frameworks/Python/django/benchmark_config.json index c4e3d51a143..601267011b4 100644 --- a/frameworks/Python/django/benchmark_config.json +++ b/frameworks/Python/django/benchmark_config.json @@ -1,89 +1,72 @@ { "framework": "django", - "tests": [{ - "default": { - "plaintext_url" : "/plaintext", - "json_url": "/json", - "db_url": "/db", - "query_url": "/dbs?queries=", - "fortune_url": "/fortunes", - "update_url": "/update?queries=", - "port": 8080, - "approach": "Realistic", - "classification": "Fullstack", - "database": "MySQL", - "framework": "django", - "language": "Python", - "flavor": "Python3", - "orm": "Full", - "platform": "WSGI", - "webserver": "Gunicorn", - "os": "Linux", - "database_os": "Linux", - "display_name": "Django", - "notes": "", - "versus": "wsgi", - "tags": [ ] - }, - "socketify-wsgi": { - "plaintext_url" : "/plaintext", - "json_url": "/json", - "port": 8080, - "approach": "Realistic", - "classification": "Fullstack", - "database": "None", - "framework": "django", - "language": "Python", - "flavor": "Python3", - "orm": "Raw", - "platform": "WSGI", - "webserver": "Socketify.py", - "os": "Linux", - "database_os": "Linux", - "display_name": "Django [Socketify.py WSGI]", - "notes": "", - "versus": "wsgi" - }, - "socketify-wsgi-pypy": { - "plaintext_url" : "/plaintext", - "json_url": "/json", - "port": 8080, - "approach": "Realistic", - "classification": "Fullstack", - "database": "None", - "framework": "django", - "language": "Python", - "flavor": "PyPy3", - "orm": "Raw", - "platform": "WSGI", - "webserver": "Socketify.py", - "os": "Linux", - "database_os": "Linux", - "display_name": "Django [Socketify.py WSGI PyPy3]", - "notes": "", - "versus": "wsgi" - }, - "postgresql": { - "db_url": "/db", - "query_url": "/dbs?queries=", - "fortune_url": "/fortunes", - "update_url": "/update?queries=", - "port": 8080, - "approach": "Realistic", - "classification": "Fullstack", - "database": "Postgres", - "framework": "django", - "language": "Python", - "flavor": "Python3", - "orm": "Full", - "platform": "WSGI", - "webserver": "Gunicorn", - "os": "Linux", - "database_os": "Linux", - "display_name": "Django [Postgres]", - "notes": "", - "versus": "wsgi", - "tags": [ ] + "tests": [ + { + "default": { + "plaintext_url": "/plaintext", + "json_url": "/json", + "db_url": "/db", + "query_url": "/dbs?queries=", + "fortune_url": "/fortunes", + "update_url": "/update?queries=", + "port": 8080, + "approach": "Realistic", + "classification": "Fullstack", + "database": "MySQL", + "framework": "django", + "language": "Python", + "flavor": "Python3", + "orm": "Full", + "platform": "WSGI", + "webserver": "Gunicorn", + "os": "Linux", + "database_os": "Linux", + "display_name": "Django", + "notes": "", + "versus": "wsgi", + "tags": [] + }, + "socketify-wsgi": { + "plaintext_url": "/plaintext", + "json_url": "/json", + "port": 8080, + "approach": "Realistic", + "classification": "Fullstack", + "database": "None", + "framework": "django", + "language": "Python", + "flavor": "Python3", + "orm": "Raw", + "platform": "WSGI", + "webserver": "Socketify.py", + "os": "Linux", + "database_os": "Linux", + "display_name": "Django [Socketify.py WSGI]", + "notes": "", + "versus": "wsgi" + }, + "postgresql": { + "db_url": "/db", + "query_url": "/dbs?queries=", + "fortune_url": "/fortunes", + "update_url": "/update?queries=", + "port": 8080, + "approach": "Realistic", + "classification": "Fullstack", + "database": "Postgres", + "framework": "django", + "language": "Python", + "flavor": "Python3", + "orm": "Full", + "platform": "WSGI", + "webserver": "Gunicorn", + "os": "Linux", + "database_os": "Linux", + "display_name": "Django [Postgres]", + "notes": "", + "versus": "wsgi", + "tags": [] + } } - }] -} + ] +} \ No newline at end of file diff --git a/frameworks/Python/django/config.toml b/frameworks/Python/django/config.toml index 592e487389c..85ecc8f9e04 100644 --- a/frameworks/Python/django/config.toml +++ b/frameworks/Python/django/config.toml @@ -15,7 +15,7 @@ database_os = "Linux" os = "Linux" orm = "Full" platform = "WSGI" -webserver = "Meinheld" +webserver = "Gunicorn" versus = "wsgi" [socketify-wsgi] @@ -31,19 +31,6 @@ platform = "WSGI" webserver = "Socketify.py" versus = "wsgi" -[socketify-wsgi-pypy] -urls.plaintext = "/plaintext" -urls.json = "/json" -approach = "Realistic" -classification = "Fullstack" -database = "MySQL" -database_os = "Linux" -os = "Linux" -orm = "Raw" -platform = "WSGI" -webserver = "Socketify.py" -versus = "wsgi" - [postgresql] urls.db = "/db" urls.query = "/dbs?queries=" @@ -56,5 +43,5 @@ database_os = "Linux" os = "Linux" orm = "Full" platform = "WSGI" -webserver = "Meinheld" +webserver = "Gunicorn" versus = "wsgi" diff --git a/frameworks/Python/django/django-postgresql.dockerfile b/frameworks/Python/django/django-postgresql.dockerfile index ff554710097..8a4cc4729f4 100644 --- a/frameworks/Python/django/django-postgresql.dockerfile +++ b/frameworks/Python/django/django-postgresql.dockerfile @@ -1,4 +1,4 @@ -FROM python:3.12-bullseye +FROM python:3.13-bullseye ADD ./ /django diff --git a/frameworks/Python/django/django-socketify-wsgi-pypy.dockerfile b/frameworks/Python/django/django-socketify-wsgi-pypy.dockerfile deleted file mode 100644 index 54a2429a10c..00000000000 --- a/frameworks/Python/django/django-socketify-wsgi-pypy.dockerfile +++ /dev/null @@ -1,11 +0,0 @@ -FROM pypy:3.9-bullseye - -ADD ./ /django - -WORKDIR /django -RUN apt-get update; apt-get install libuv1 -y -RUN pip install -r /django/requirements-socketify.txt - -EXPOSE 8080 - -CMD python ./django-socketify-wsgi.py diff --git a/frameworks/Python/django/django-socketify-wsgi.dockerfile b/frameworks/Python/django/django-socketify-wsgi.dockerfile index 5ab6e9dcd67..41e738c2c5b 100644 --- a/frameworks/Python/django/django-socketify-wsgi.dockerfile +++ b/frameworks/Python/django/django-socketify-wsgi.dockerfile @@ -1,10 +1,12 @@ -FROM python:3.10-bullseye +FROM python:3.13-bullseye ADD ./ /django WORKDIR /django -RUN apt-get update; apt-get install libuv1 -y -RUN pip install -r /django/requirements-socketify.txt + +RUN apt-get update && \ + apt-get install gcc g++ make libuv1 zlib1g -y && \ + pip install -r /django/requirements-socketify.txt EXPOSE 8080 diff --git a/frameworks/Python/django/django.dockerfile b/frameworks/Python/django/django.dockerfile index a5b5182eabf..a632e2ffcb4 100644 --- a/frameworks/Python/django/django.dockerfile +++ b/frameworks/Python/django/django.dockerfile @@ -1,4 +1,4 @@ -FROM python:3.12-bullseye +FROM python:3.13-bullseye ADD ./ /django diff --git a/frameworks/Python/django/hello/hello/settings.py b/frameworks/Python/django/hello/hello/settings.py index fac79954d14..02268ad767b 100644 --- a/frameworks/Python/django/hello/hello/settings.py +++ b/frameworks/Python/django/hello/hello/settings.py @@ -2,66 +2,66 @@ DEBUG = False -SECRET_KEY = '_7mb6#v4yf@qhc(r(zbyh&z_iby-na*7wz&-v6pohsul-d#y5f' +SECRET_KEY = "_7mb6#v4yf@qhc(r(zbyh&z_iby-na*7wz&-v6pohsul-d#y5f" ADMINS = () MANAGERS = ADMINS -_django_db = os.getenv('DJANGO_DB', "") +_django_db = os.getenv("DJANGO_DB", "") DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.' + _django_db, # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. - 'NAME': 'hello_world', # Or path to database file if using sqlite3. - 'USER': 'benchmarkdbuser', # Not used with sqlite3. - 'PASSWORD': 'benchmarkdbpass', # Not used with sqlite3. - 'HOST': 'tfb-database', # Set to empty string for localhost. Not used with sqlite3. - 'PORT': '', # Set to empty string for default. Not used with sqlite3. - 'CONN_MAX_AGE': 30, + "default": { + "ENGINE": "django.db.backends." + + _django_db, # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. + "NAME": "hello_world", # Or path to database file if using sqlite3. + "USER": "benchmarkdbuser", # Not used with sqlite3. + "PASSWORD": "benchmarkdbpass", # Not used with sqlite3. + "HOST": "tfb-database", # Set to empty string for localhost. Not used with sqlite3. + "PORT": "", # Set to empty string for default. Not used with sqlite3. + "CONN_MAX_AGE": 30, } } if not _django_db: - DATABASES = { } + DATABASES = {} -TIME_ZONE = 'America/Chicago' -LANGUAGE_CODE = 'en-us' +TIME_ZONE = "America/Chicago" +LANGUAGE_CODE = "en-us" USE_I18N = False USE_L10N = False USE_TZ = False -MEDIA_ROOT = '' -MEDIA_URL = '' -STATIC_ROOT = '' -STATIC_URL = '/static/' +MEDIA_ROOT = "" +MEDIA_URL = "" +STATIC_ROOT = "" +STATIC_URL = "/static/" STATICFILES_DIRS = () STATICFILES_FINDERS = () MIDDLEWARE = () -ROOT_URLCONF = 'hello.urls' -WSGI_APPLICATION = 'hello.wsgi.application' +ROOT_URLCONF = "hello.urls" +WSGI_APPLICATION = "hello.wsgi.application" TEMPLATES = [ { - 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [], - 'APP_DIRS': True, - 'OPTIONS': {}, + "BACKEND": "django.template.backends.django.DjangoTemplates", + "DIRS": [], + "APP_DIRS": True, + "OPTIONS": {}, }, ] INSTALLED_APPS = ( - 'django.contrib.contenttypes', - 'django.contrib.sessions', - 'world', + "django.contrib.contenttypes", + "django.contrib.sessions", + "world", ) LOGGING = { - 'version': 1, - 'disable_existing_loggers': True, - 'handlers': {}, - 'loggers': {}, - + "version": 1, + "disable_existing_loggers": True, + "handlers": {}, + "loggers": {}, } -ALLOWED_HOSTS = ['*'] +ALLOWED_HOSTS = ["*"] diff --git a/frameworks/Python/django/hello/hello/urls.py b/frameworks/Python/django/hello/hello/urls.py index fbf2fbbfa97..d622f3414d8 100644 --- a/frameworks/Python/django/hello/hello/urls.py +++ b/frameworks/Python/django/hello/hello/urls.py @@ -1,11 +1,11 @@ -from django.conf.urls import url +from django.urls import path from world.views import plaintext, json, db, dbs, fortunes, update urlpatterns = [ - url(r'^plaintext$', plaintext), - url(r'^json$', json), - url(r'^db$', db), - url(r'^dbs$', dbs), - url(r'^fortunes$', fortunes), - url(r'^update$', update), + path("plaintext", plaintext), + path("json", json), + path("db", db), + path("dbs", dbs), + path("fortunes", fortunes), + path("update", update), ] diff --git a/frameworks/Python/django/hello/hello/wsgi.py b/frameworks/Python/django/hello/hello/wsgi.py index 717367e2872..1febb6fdb65 100644 --- a/frameworks/Python/django/hello/hello/wsgi.py +++ b/frameworks/Python/django/hello/hello/wsgi.py @@ -1,21 +1,7 @@ -""" -WSGI config for hello project. - -This module contains the WSGI application used by Django's development server -and any production WSGI deployments. It should expose a module-level variable -named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover -this application via the ``WSGI_APPLICATION`` setting. - -Usually you will have the standard Django WSGI application here, but it also -might make sense to replace the whole Django WSGI application with a custom one -that later delegates to the Django one. For example, you could introduce WSGI -middleware here, or combine a Django application with an application of another -framework. - -""" import os os.environ.setdefault("DJANGO_SETTINGS_MODULE", "hello.settings") from django.core.wsgi import get_wsgi_application + application = get_wsgi_application() diff --git a/frameworks/Python/django/hello/world/models.py b/frameworks/Python/django/hello/world/models.py index 4756e2b06cd..a243e8bb47a 100644 --- a/frameworks/Python/django/hello/world/models.py +++ b/frameworks/Python/django/hello/world/models.py @@ -5,11 +5,11 @@ class World(models.Model): randomnumber = models.IntegerField() class Meta: - db_table = 'world' + db_table = "world" class Fortune(models.Model): message = models.CharField(max_length=65535) class Meta: - db_table = 'fortune' + db_table = "fortune" diff --git a/frameworks/Python/django/hello/world/views.py b/frameworks/Python/django/hello/world/views.py index 5dd6a35f35f..47fa887fe44 100644 --- a/frameworks/Python/django/hello/world/views.py +++ b/frameworks/Python/django/hello/world/views.py @@ -1,9 +1,9 @@ import random from operator import itemgetter from functools import partial -from ujson import dumps as uj_dumps +from orjson import dumps -from django.http import HttpResponse +from django.http import HttpResponse, StreamingHttpResponse from django.shortcuts import render from world.models import World, Fortune @@ -14,7 +14,7 @@ def _get_queries(request): try: - queries = int(request.GET.get('queries', 1)) + queries = int(request.GET.get("queries", 1)) except Exception: queries = 1 if queries < 1: @@ -25,22 +25,18 @@ def _get_queries(request): def plaintext(request): - return HttpResponse("Hello, World!", content_type="text/plain") + return StreamingHttpResponse("Hello, World!", content_type="text/plain") def json(request): return HttpResponse( - uj_dumps({"message": "Hello, World!"}), - content_type="application/json" - ) + dumps({"message": "Hello, World!"}), content_type="application/json" + ) def db(request): r = _random_int() - world = uj_dumps({ - 'id': r, - 'randomNumber': World.objects.get(id=r).randomnumber - }) + world = dumps({"id": r, "randomNumber": World.objects.get(id=r).randomnumber}) return HttpResponse(world, content_type="application/json") @@ -49,18 +45,19 @@ def dbs(request): def caller(input_): int_ = _random_int() - return {'id': int_, 'randomNumber': World.objects.get(id=int_).randomnumber} + return {"id": int_, "randomNumber": World.objects.get(id=int_).randomnumber} + worlds = tuple(map(caller, range(queries))) - return HttpResponse(uj_dumps(worlds), content_type="application/json") + return HttpResponse(dumps(worlds), content_type="application/json") def fortunes(request): - fortunes = list(Fortune.objects.values('id', 'message')) - fortunes.append({"id": 0, 'message': "Additional fortune added at request time."}) - fortunes.sort(key=itemgetter('message')) + fortunes = list(Fortune.objects.values("id", "message")) + fortunes.append({"id": 0, "message": "Additional fortune added at request time."}) + fortunes.sort(key=itemgetter("message")) - return render(request, 'fortunes.html', {'fortunes': fortunes}) + return render(request, "fortunes.html", {"fortunes": fortunes}) def update(request): @@ -70,7 +67,8 @@ def caller(input_): w = World.objects.get(id=_random_int()) w.randomnumber = _random_int() w.save() - return {'id': w.id, 'randomNumber': w.randomnumber} + return {"id": w.id, "randomNumber": w.randomnumber} + worlds = tuple(map(caller, range(queries))) - return HttpResponse(uj_dumps(worlds), content_type="application/json") + return HttpResponse(dumps(worlds), content_type="application/json") diff --git a/frameworks/Python/django/requirements-gunicorn.txt b/frameworks/Python/django/requirements-gunicorn.txt index 7ec2e47c136..f6d2efaf67e 100644 --- a/frameworks/Python/django/requirements-gunicorn.txt +++ b/frameworks/Python/django/requirements-gunicorn.txt @@ -1,4 +1,3 @@ -r requirements.txt -greenlet==3.1.1 -gunicorn==21.2.0 -gevent==24.10.2 \ No newline at end of file + +gunicorn==23.0.0 \ No newline at end of file diff --git a/frameworks/Python/django/requirements.txt b/frameworks/Python/django/requirements.txt index c7765c2c549..97702f79234 100644 --- a/frameworks/Python/django/requirements.txt +++ b/frameworks/Python/django/requirements.txt @@ -1,5 +1,5 @@ -Django==3.2.25 -mysqlclient==2.2.6 -psycopg2==2.9.9; implementation_name=='cpython' -pytz==2023.2 -ujson==5.8.0 +Django==5.2.6 +mysqlclient==2.2.7 +psycopg2-binary==2.9.10 +pytz==2025.2 +orjson==3.11.3 \ No newline at end of file