ttvdrops/config/urls.py
Joakim Hellsén e968f5cdea
Add Silk middleware and related settings for performance monitoring
- Introduced SILK_ENABLED setting to toggle Silk middleware.
- Updated ALLOWED_HOSTS to include "testserver" when not in DEBUG mode.
- Modified urlpatterns to conditionally include Silk URLs.
- Added django-silk dependency to pyproject.toml.
- Enhanced feed queries to optimize performance and reduce N+1 issues.
- Updated tests to verify query limits for various feeds.
2026-02-09 20:02:19 +01:00

26 lines
742 B
Python

from __future__ import annotations
from typing import TYPE_CHECKING
from django.conf import settings
from django.conf.urls.static import static
from django.urls import include
from django.urls import path
if TYPE_CHECKING:
from django.urls.resolvers import URLPattern
from django.urls.resolvers import URLResolver
urlpatterns: [URLPattern | URLResolver] = [ # type: ignore[assignment]
path(route="", view=include("twitch.urls", namespace="twitch")),
]
if getattr(settings, "ENABLE_SILK", False):
urlpatterns += [path("silk/", include("silk.urls", namespace="silk"))]
# Serve media in development
if settings.DEBUG:
urlpatterns += static(
settings.MEDIA_URL,
document_root=settings.MEDIA_ROOT,
)