The backend uses python-decouple to load configuration from aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/AC42027/Backend-produccion/llms.txt
Use this file to discover all available pages before exploring further.
.env file at the project root. Every value marked as required below must be present or the application will raise an error on startup. Values with defaults are optional but should be reviewed before deploying to production.
Complete .env example
The following file shows every supported variable with representative values. Copy it to the project root and fill in the values for your environment:.env
Environment variables
Django core
| Variable | Required | Default | Description |
|---|---|---|---|
SECRET_KEY | Yes | — | Django’s cryptographic signing key. Use a long, random string unique to each environment. |
DEBUG | No | False | Set to True only in local development. Never enable in production. |
ALLOWED_HOSTS | Yes | — | Comma-separated list of hostnames or IP addresses the server will respond to (e.g. localhost,127.0.0.1,10.107.202.51). |
CSRF_TRUSTED_ORIGINS | No | [] | Comma-separated list of origins trusted for CSRF-protected requests (e.g. http://localhost:3010). Required when the frontend sends cookies cross-origin. |
Database (MySQL)
| Variable | Required | Default | Description |
|---|---|---|---|
MYSQL_DATABASE | Yes | — | Name of the MySQL database (e.g. inspecciones). |
MYSQL_USER | Yes | — | MySQL username with read/write access to MYSQL_DATABASE. |
MYSQL_PASSWORD | Yes | — | Password for MYSQL_USER. |
MYSQL_HOST | Yes | — | Hostname or IP address of the MySQL server. |
MYSQL_PORT | No | 3306 | TCP port the MySQL server listens on. |
The backend connects to MySQL via PyMySQL, which is registered as a drop-in replacement for MySQLdb. The database connection enforces
STRICT_TRANS_TABLES mode to prevent silent data truncation.LDAP authentication
| Variable | Required | Default | Description |
|---|---|---|---|
LDAP_SERVER | Yes | — | Hostname or IP address of the Active Directory / LDAP server (e.g. ldap.miempresa.local). |
LDAP_DOMAIN | Yes | — | Domain suffix appended to usernames when binding (e.g. miempresa.local). Credentials are sent as username@miempresa.local. |
CORS
| Variable | Required | Default | Description |
|---|---|---|---|
CORS_ALLOW_ALL_ORIGINS | No | False | Set to True to allow requests from any origin. Do not use in production. |
CORS_ALLOWED_ORIGINS | Conditional | — | Comma-separated list of allowed origins (e.g. http://localhost:3010,http://10.107.202.51:3010). Required when CORS_ALLOW_ALL_ORIGINS is False. |
The frontend is a Next.js application. Make sure the value in
CORS_ALLOWED_ORIGINS and CSRF_TRUSTED_ORIGINS reflects the exact origin the browser uses to reach the frontend, including the port number.Session configuration
Session behaviour is fixed insettings.py and is not configurable via .env:
| Setting | Value | Description |
|---|---|---|
SESSION_COOKIE_AGE | 3600 seconds (1 hour) | Sessions expire after one hour of inactivity. |
SESSION_SAVE_EVERY_REQUEST | True | The expiry timer resets on every request, keeping the session alive as long as the user is active. |
SESSION_EXPIRE_AT_BROWSER_CLOSE | False | Closing the browser tab does not invalidate the session. |
IP restrictions
Access to most API endpoints is limited to requests from specific IP ranges or registered hostnames. This policy is enforced by theRestringirIPMiddleware middleware and is configured directly in settings.py — not via .env.
Allowed IP prefixes — requests from addresses in these subnets are permitted: