Skip to content

Utils

rn_forge.django.drf.utils

Typed helpers for working with Django REST Framework request objects.

AuthenticatedRequestUser

Bases: Protocol

Minimum user shape expected by DRF-facing library helpers.

PermissionAwareUser

Bases: AuthenticatedRequestUser, Protocol

User shape required by permission-aware DRF helpers.

RequestUtils

Typed boundary helpers for DRF request objects.

These helpers centralize the narrow Pyright workarounds needed around DRF's request, user, and auth attributes so view and auth modules can use a small stable API instead of scattering casts and ignores.

get_data(request) staticmethod

Return request data normalized to a plain dict[str, Any].

get_django_request(request) staticmethod

Return the underlying Django request from a DRF request.

get_param(request, key, default=None) staticmethod

Return a query-parameter value from the request.

get_request_auth(request) staticmethod

Return the current request auth payload.

get_request_user(request) staticmethod

Return the current request user with a stable typed protocol.

get_string(request, key, default=None) staticmethod

Return a query/body value converted to str when present.

get_uploaded_file(request, key='file') staticmethod

Return an uploaded file or raise a DRF validation error.

get_value(request, key, default=None) staticmethod

Return a value from request data.