Skip to content
Henry Mehta edited this page Dec 10, 2024 · 7 revisions

Environment variables can be held in a .env file in the webcdi directory (at the same level as manage.py). If any of these variables are set up at environment level, that specification will take priority.

AWS Variables

If using AWS, database passwords are rotated. This requires some specialised code so we need to specify if this is an AWS instance.

AWS_INSTANCE=0 # default is 1. If AWS is not being used, set to 0

AWS_ACCESS_KEY_ID=<AWS_ACCESS_KEY_ID> # required if AWS instance, otherwise do not include

AWS_SECRET_ACCESS_KEY=<AWS_SECRET_KEY_ID> # required if AWS instance, otherwise do not include

EMAIL_BACKEND='django.core.mail.backends.console.EmailBackend' # For local work use django.core.mail.backends.console.EmailBackend. This will print emails to the console. For a server instance use django.core.mail.backends.smtp.EmailBackend. If you're using AWS, you can use AWS SES, in which case use django_ses.SESBackend. SES is the default. If using `django_ses.SESBackend, you must set AWS_SES_REGION_NAME and AWS_SES_REGION_ENDPOINT.

AWS_SES_REGION_NAME = "us-west-2" # required if email backend in SES. us-west-2 is the default

AWS_SES_REGION_ENDPOINT = "email.us-west-2.amazonaws.com" # required if email backend in SES. email.us-west-2.amazonaws.com is the default.

AWS_STORAGE_BUCKET_NAME = 'webcdi-media-dev' # create an S3 bucket with the desired location and enter it here

Database Settings

RDS_ENGINE='django.db.backends.postgresql' The default engine is django.db.backends.postgresql. If using AWS, you can set the engine to webcdi_postgresql_engine which will allow you to use the AWS secrets manager. If using this option the system will look for a password in us-west-2 under this string f"{os.environ.get('DJANGO_SERVER_TYPE','dev').lower()}/webcdi/RDS_PASSWORD". Please note, sqlite is not an option because it cannot handle the database complexities. If running locally, use docker.

RDS_DB_NAME=<database_name> # required

RDS_USERNAME=<database_username> # required

RDS_PASSWORD=<database_password> # required

RDS_HOSTNAME=<database_hostname> # required

RDS_PORT=<database_port> # required

EMAIL Settings

EMAIL_BACKEND='django.core.mail.backends.console.EmailBackend' # For local work use django.core.mail.backends.console.EmailBackend. This will print emails to the console. For a server instance use django.core.mail.backends.smtp.EmailBackend. If you're using AWS, you can use AWS SES, in which case use django_ses.SESBackend. SES is the default. If using `django_ses.SESBackend, you must set AWS_SES_REGION_NAME and AWS_SES_REGION_ENDPOINT. Please note, this is the same as the variable mentioned in the AWS section above.

EMAIL_PORT=25 # email port to be used. Default is 25

DEFAULT_FROM_EMAIL_NAME='WebCDI Local' # Required Name given in emails sent to users

DEFAULT_FROM_EMAIL_ADDRESS='[email protected]' # Required email address used

DEFAULT_RECIPIENT_EMAIL='[email protected]' # Required

BROOKES_EMAIL='[email protected]' # Required. Please leave at this in production unless Brookes ask us to change. Spanish and English Long and CAT forms now require payment. Payment is made through Brookes. The emails tell Brookes how the validation codes are used.

ADMINS = '[("admin1_name", "[email protected]"), ("admin2_name", "[email protected]")]' # Required. Imported using JSON so include the single quotes in the .env file. A list of email addresses of site admins where error messages are sent

Home page links

CONTACT_EMAIL = "[email protected]" # this is the default

MORE_INFO_ADDRESS = "http://mb-cdi.stanford.edu/" # this is the default

Other

ALLOWED_HOSTS='["web", "test", "localhost", "127.0.0.2", "127.0.0.1"]' # imported using JSON so include the single quotes in the .env file. This is a list of urls allowed to use the site. Displayed are those used in local development and test. For server '[".webcdi.org"]' will enable anything ending in webcdi.org

LOG_FILE_PATH='/tmp/' # path to where error files is located. Default is /tmp/

DEBUG=0 # 0 or 1. Default is 0 (False) for production environment. If you want to see error messages, set to 1

DJANGO_SERVER_TYPE='DEV' # DEV or PROD

SITE_ID=3 # 1=WebCDI, 2= WebCDI Test, 3= Local, 4=MPI

PRIMARY_HOST=<primary_host> # if you want the site redirected to a specific url, set it here. For example, setting it to www.my_primary.org will redirect my_primary.org to www.my_primary.org. It is not required

TIME_ZONE='UTC' UTC is the default but if running elsewhere you may need to enter the local timezone. Timezone identifiers can be found here: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones

TRUSTED_ORIGINS # default is blank. If you need to the the Django CSRF_TRUSTED_ORIGINS you can set it using the TRUSTED_ORIGINS enviornmental variable in the same format as used for ALLOWED_HOSTS