Repository navigation
DRF Configuration
This page provides an overview of the Django Rest Framework (DRF) configuration within The Wall API. It covers core settings in config/settings.py and dynamic configurations from env_utils.py.
The DRF core settings are defined in config/settings.py under the REST_FRAMEWORK dictionary:
-
Installed Apps:
-
rest_framework: Core DRF package. -
rest_framework.authtoken: Enables token-based authentication. -
drf_spectacular: Generates API documentation and schemas. -
djoser: Provides user authentication endpoints.
-
-
Versioning:
-
DEFAULT_VERSIONING_CLASS: UsesURLPathVersioningto extract the API version from the URL (e.g.,/api/v2/). -
DEFAULT_VERSION: Sets the active API version to"v2". -
ALLOWED_VERSIONS: Limits available API versions to["v2"].
-
The following settings adjust dynamically based on the project environment, using env_utils.py:
-
Project Mode:
-
PROJECT_MODE: Determines whether the app runs in dev, prod_v1, or prod_v2 mode.
-
-
PostgreSQL Configuration:
- Used as the primary database for the application.
💡 For details, refer to the PostgreSQL page.
- Used as the primary database for the application.
-
Redis Configuration:
- Used for caching, Celery task management, and session storage.
💡 For more information, refer to the Redis page.
- Used for caching, Celery task management, and session storage.
-
Celery Configuration:
- Handles asynchronous task execution.
- Configured dynamically via
env_utils.py.
💡 For full configuration, refer to the Celery page.
These settings enforce password validation rules and optimize session storage efficiency.
-
Session Engine:
-
SESSION_ENGINEis set to use Django’s cache-based session storage viadjango.contrib.sessions.backends.cache. - This allows session data to be stored in Redis, improving performance by avoiding database writes for session-related data.
-
-
Password Validation:
- Defined in
AUTH_PASSWORD_VALIDATORS, including:UserAttributeSimilarityValidatorMinimumLengthValidatorCommonPasswordValidatorNumericPasswordValidator
- Defined in
API documentation is generated with DRF Spectacular, supporting OpenAPI schema generation.
- The schema is exposed using
DEFAULT_SCHEMA_CLASS=drf_spectacular.openapi.AutoSchema. - OpenAPI versioning is configured under
SPECTACULAR_SETTINGS.
💡 For details, refer to the DRF Spectacular page.
Logging is configured to capture application errors, Celery tasks, caching issues, and API interactions. It includes:
- File-based logging for different components such as caching, Celery, and wall configuration.
- Console logging for immediate debugging feedback.
- Test suite logging to track testing outcomes.
💡 For full details, refer to the Logging Details page.
The application relies on environment variables for configuring database connections, Redis, Celery, logging, and general application behavior. These settings are managed in .env files and dynamically loaded by env_utils.py.
💡 For a detailed breakdown, see the Environment Variables Index page.
- Authentication (Djoser)
- Environment Variables Index
- PostgreSQL
- Redis
- Celery
- DRF Spectacular
- Logging Details
Return to Top
DRF Index
DTS Index
Home Page
📌 Notable Technical Sections
👤 Author
LinkedIn: Aleksandar Dimitrov
Yahoo: sasho_1983@yahoo.com