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 provides references to dedicated pages for related configurations.
- DRF Core Settings
- Environment-Based Configuration
- Session Management and Password Validation
- API Schema and Documentation
- Logging
- Environment Variables
The DRF core settings are defined in 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 project's configuration adjusts to the environment and is dynamically set in the_wall_api/utils/env_utils.py.
-
Project Mode:
- The
PROJECT_MODEenvironment variable sets the runtime environment to dev, demo, prod_v1, or prod_v2.
- The
-
PostgreSQL Configuration:
- Database settings are organized within the
DATABASESdictionary.
💡 For details, refer to the PostgreSQL - Database Configuration page.
- Database settings are organized within the
-
Redis Configuration:
- Handles caching, Celery task queuing, and session storage.
💡 For a full breakdown, refer to the Redis - In-Memory Cache & Celery Message Broker page.
- Handles caching, Celery task queuing, and session storage.
-
Celery Configuration:
- Manages asynchronous task execution.
💡 See the Celery - Asynchronous Task Processing page for a comprehensive list of settings.
- Manages asynchronous task execution.
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
DRF Spectacular generates API documentation and defines OpenAPI schemas.
-
DEFAULT_SCHEMA_CLASSis set todrf_spectacular.openapi.AutoSchemato enable schema generation. - OpenAPI versioning is configured under
SPECTACULAR_SETTINGS.
💡 For details, refer to the DRF Spectacular page.
Logging is configured to capture application errors, caching issues, Celery tasks output, 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 Error Logging section of the Error Handling page.
The application relies on environment variables for configuring database connections, Redis, Celery, logging, concurrency, and wall configuration settings.
These settings are managed in various .env files:
-
Common (
config/env/common/)-
redis.conf→ Redis memory and persistence settings.
-
-
Development (
config/env/dev/)-
postgres_dev.env→ PostgreSQL credentials. -
the_wall_api_dev.env→ General application settings.
-
-
Production (
config/env/prod/)-
postgres_prod.env→ PostgreSQL credentials. -
redis_prod.env→ Redis authentication. -
the_wall_api_prod.env→ General application settings.
-
💡 For a detailed breakdown, see the Environment Variables Index page.
💡 Check the *.example files in the relevant folders of the repository for example configuration values.
Next: API URL Routing
Back to: Project Folder Structure
Return to Top
DTS Index
Home Page
📌 Notable Technical Sections
👤 Author
LinkedIn: Aleksandar Dimitrov
Yahoo: sasho_1983@yahoo.com