Django ๐
First launch a PostgreSQL Server job to be able to connect it later on to this Django job.
Parameters
postgres.database.ucloud.sdu.dk
๐ is the hostname string to connect to the running PostgreSQL Server job.
๐ See also DjangoJobParameters.json template.
Usage
-
Once the Django job has started and all the initialisation has been completed, click on the Open terminal blue button in the top right corner.
-
In Terminal navigate to the ucloud folder
cd /work/ucloud
-
Then launch the script with
. main.sh
-
Then follow instructions starting after Do you want to manage Django question.
Environment variables
Available environment variables created in UCloud job to interact within Django app.
import os
...
UCLD_ALLOWED_HOSTS = os.environ.get("UCLD_ALLOWED_HOSTS", "")
UCLD_HOSTNAME = os.environ.get("UCLD_HOSTNAME", "")
UCLD_PATH_TO_DATA = os.environ.get("UCLD_PATH_TO_DATA", "")
Allowing integration with Django settings.py
ALLOWED_HOSTS = ["127.0.0.1", "localhost"]
if UCLD_HOSTNAME:
ALLOWED_HOSTS += [UCLD_HOSTNAME]
if UCLD_ALLOWED_HOSTS:
ALLOWED_HOSTS += UCLD_ALLOWED_HOSTS.split(" ")
CSRF_TRUSTED_ORIGINS = [f"https://{_host}" for _host in ALLOWED_HOSTS]
UCLD_PATH_TO_DATA = os.environ.get(
"UCLD_PATH_TO_DATA", os.path.join(BASE_DIR, "dumpdata")
)
Reading ๐
- UCloud Apps Django documentation.
Sponsorship
If this project helps you, you can offer me a cup of coffee โ๏ธ :-)