Setting your environment variables
Below is an example of what your .env
file might look like:
It is not necessary to modify all these variables at once. You can update them as needed based on the specific requirements of your application. Below is a breakdown of the key sections and what each set of environment variables controls.
Database
These variables define the connection details for your application's database:
DB_HOST
: The hostname of your database server. If using Docker, this should be set topostgres
, matching the service name in the Docker Compose file.DB_NAME
: The name of the database your application will use.DB_USER
: The username for accessing the database.DB_PASSWORD
: The password for the database user.DB_PORT
: The port number on which your database server is listening (default is 5432 for PostgreSQL).
Debug
The DEBUG
variable controls the debugging mode of your application:
DEBUG
: Set this toTrue
during development to enable detailed error pages and logs. Important: Set this toFalse
before deploying your application to production to prevent exposure of sensitive information.
Email
These variables configure your application's email delivery settings:
EMAIL_HOST
: The SMTP server your application will use to send emails.EMAIL_PORT
: The port on which the SMTP server is running.EMAIL_HOST_USER
: The username for the SMTP server.EMAIL_HOST_USER_NAME
: The name that will appear in the "From" field of outgoing emails.EMAIL_HOST_PASSWORD
: The password for the SMTP server.EMAIL_USE_TLS
: Whether to use TLS for secure email transmission (True
orFalse
).SENDGRID_API_KEY
: If using SendGrid for email, set your API key here.
If using SMTP, ensure that the EMAIL_HOST
, EMAIL_PORT
, EMAIL_HOST_USER
, EMAIL_HOST_USER_NAME
, and EMAIL_HOST_PASSWORD
are configured.
For SendGrid, use EMAIL_HOST_USER
, EMAIL_HOST_USER_NAME
, and SENDGRID_API_KEY
.
Redis
The REDIS_HOST
variable specifies the address of your Redis instance:
REDIS_HOST
: If using Docker, set this toredis
, which matches the service name in the Docker Compose file.
Secret Key
The SECRET_KEY
is a critical component for the security of your Django application:
SECRET_KEY
: This should be a unique, secret key used for cryptographic signing. You can generate a strong secret key here.
Stripe
To enable payment processing and subscription management, configure the following Stripe-related environment variables:
STRIPE_LIVE_MODE
: Set toTrue
to enable live mode, orFalse
for testing.STRIPE_PUBLIC_API_KEY
: Your public Stripe API key for live mode.STRIPE_SECRET_API_KEY
: Your secret Stripe API key for live mode.STRIPE_WEBHOOK_SECRET
: The webhook secret for Stripe in live mode.STRIPE_TEST_PUBLIC_API_KEY
: Your public Stripe API key for test mode.STRIPE_TEST_SECRET_API_KEY
: Your secret Stripe API key for test mode.STRIPE_TEST_WEBHOOK_SECRET
: The webhook secret for Stripe in test mode.
Ensure these variables are correctly set to integrate Stripe into your application effectively.
OpenAI
To enable OpenAI capabilities, set the OPENAI_API_KEY
to your key.
By configuring these environment variables, you can fine-tune how ShipWithDjango operates, ensuring it meets your project's specific needs.
Last updated