Overview
Bar Galileo uses environment variables for configuration management. Variables are loaded from a.env file located at bar_galileo/bar_galileo/.env using the python-dotenv package.
Environment File Location
Quick Setup
Environment Variables Reference
Core Django Settings
Enable or disable Django debug mode.Accepted values:
1, true, yes, True (case-insensitive)Production: Must be FalseDjango secret key for cryptographic signing.Security: Keep this value secret. Never commit to version control.Generation: Use Django’s
get_random_secret_key() or:Comma-separated list of host/domain names that Django can serve.Format:
localhost,example.com,www.example.comExample: localhost,bar-galileo.com,192.168.1.100Database Configuration
MySQL/MariaDB database name.
MySQL/MariaDB database user.
MySQL/MariaDB database password.Security: Use a strong password in production.
MySQL/MariaDB database host.Examples:
localhost, 127.0.0.1, db.example.comMySQL/MariaDB database port.
Email Configuration
Gmail email address for sending system emails.Example:
[email protected]Gmail App Password (not your regular Gmail password).How to generate:
- Enable 2-factor authentication on your Google account
- Visit https://myaccount.google.com/apppasswords
- Generate a new app password
- Use the 16-character password in this field
Gmail App Passwords are different from your regular password. You must enable 2FA to generate app passwords.
Environment File Templates
Development Template
Database Setup
MySQL/MariaDB Initial Configuration
After setting environment variables, create the database:Production Security Checklist
Auto-Enabled Production Settings
WhenDEBUG=False, these security features are automatically enabled:
settings.py
Environment Variable Loading
Bar Galileo loads environment variables usingpython-dotenv:
settings.py
Variable Access in Code
Common Issues
.env File Not Found
If environment variables aren’t loading:Check file location
The
.env file must be in bar_galileo/bar_galileo/.env (same directory as settings.py)Database Connection Errors
Access denied for user
Access denied for user
Check Enter the password from your
DB_USER and DB_PASSWORD are correct:.env file.Unknown database
Unknown database
Create the database:
Can't connect to MySQL server
Can't connect to MySQL server
Check
DB_HOST and DB_PORT:Email Configuration Issues
Authentication failed
Authentication failed
- Ensure you’re using a Gmail App Password, not your regular password
- Enable 2-factor authentication on your Google account
- Generate a new app password at https://myaccount.google.com/apppasswords
SMTPException: STARTTLS extension not supported
SMTPException: STARTTLS extension not supported
Check that
EMAIL_PORT=587 and EMAIL_USE_TLS=True are set correctly in settings.pyDefault Values Summary
| Variable | Default Value | Required | Environment |
|---|---|---|---|
DEBUG | True | No | All |
secret_key | Auto-generated | Yes (production) | All |
ALLOWED_HOSTS | * (if DEBUG) | Yes (production) | All |
DB_NAME | bar_galileo | No | All |
DB_USER | bar_galileo_user | No | All |
DB_PASSWORD | Galileo2025 | Yes (production) | All |
DB_HOST | localhost | No | All |
DB_PORT | 3306 | No | All |
emailHost | None | Yes | All |
emailPassword | None | Yes | All |
Security Best Practices
Never Commit .env
Add
.env to .gitignore to prevent accidental commitsUse Strong Passwords
Generate secure random passwords for production
Rotate Secrets
Regularly update SECRET_KEY and passwords
Limit Permissions
Use restricted database user permissions in production
Related Documentation
Django Settings
Complete Django settings reference
Deployment Guide
Production deployment instructions
