Skip to content

Commit 8c65f57

Browse files
committed
Django admin rendering
1 parent b4ef8d5 commit 8c65f57

6 files changed

Lines changed: 171 additions & 28 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Django
2+
__pycache__/
3+
*.pyc
4+
*.pyo
5+
*.pyd
6+
.Python
7+
db.sqlite3
8+
9+
# Environment
10+
.env
11+
.venv
12+
13+
# IDE
14+
.vscode/
15+
.idea/
16+
17+
# Mac
18+
.DS_Store
19+
20+
latest.pstats

test-django-admin-query-perf/django_admin_sentry_perf/settings.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
# SECURITY WARNING: don't run with debug turned on in production!
2727
DEBUG = True
2828

29-
ALLOWED_HOSTS = []
29+
ALLOWED_HOSTS = ['localhost', '127.0.0.1', 'testserver']
3030

3131

3232
# Application definition
@@ -143,4 +143,5 @@
143143
environment=os.environ.get("SENTRY_ENV", "local"),
144144
traces_sample_rate=1.0,
145145
profiles_sample_rate=1.0,
146+
debug=True,
146147
)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# The gunicorn "configuration" file
2+
3+
import cProfile
4+
5+
profile = cProfile.Profile()
6+
7+
def pre_request(worker, req):
8+
print("enabling profile for the request")
9+
profile.enable()
10+
11+
def post_request(worker, req, *args):
12+
profile.disable()
13+
print("request done, profile disabled now")
14+
15+
def worker_exit(server, worker):
16+
# Write pstats to file that can then by viewed with snakeviz
17+
# profile.dump_stats("latest.pstats")
18+
19+
# Print stats to console
20+
profile.print_stats()
21+
22+
print("process exiting, dumping stats to file")

test-django-admin-query-perf/pyproject.toml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
[project]
22
name = "test"
33
version = "0"
4-
# requires-python = "==3.11.11"
5-
requires-python = "==3.13.5"
4+
requires-python = "==3.11.11"
5+
# requires-python = "==3.13.5"
66

77
dependencies = [
88
"ipdb>=0.13.13",
99
"sentry-sdk[django]",
1010
"daphne>=4.2.1",
11-
# "django~=4.2.0",
12-
"django>=5.2.5",
11+
# "django~=4.2.24",
12+
"django===5.0",
1313
"psycopg>=3.1.0",
1414
"gunicorn>=23.0.0",
1515
"whitenoise>=6.5.0",
16+
"uvicorn>=0.35.0",
17+
"uwsgi>=2.0.30",
18+
"snakeviz>=2.2.2",
1619
]
1720

1821
# comment this out to install from pypi

test-django-admin-query-perf/run-gunicorn.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ if ! command -v uv &> /dev/null; then
88
curl -LsSf https://astral.sh/uv/install.sh | sh
99
fi
1010

11+
uv sync
12+
1113
# Run Django with Gunicorn
1214
export SENTRY_ENV=gunicorn
13-
uv run gunicorn --bind 0.0.0.0:8000 django_admin_sentry_perf.wsgi:application
15+
uv run gunicorn --bind 0.0.0.0:8000 --timeout 50000 django_admin_sentry_perf.wsgi:application
16+
17+
# Run Django with Gunicorn with async worker
18+
# export SENTRY_ENV=gunicorn
19+
# uv run gunicorn -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:8000 django_admin_sentry_perf.asgi:application
20+
21+
# Run Django with uWSGI
22+
# export SENTRY_ENV=uwsgi
23+
# uv run uwsgi --http :8000 --module django_admin_sentry_perf.wsgi

0 commit comments

Comments
 (0)