This is a template for an Django application that can be deployed in IRIS as an native Web Application.
- Clone the repository
- Create a virtual environment
- Install the requirements
- Run the docker-compose file
git clone
cd iris-django-template
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
docker-compose up
The base URL is http://localhost:53795/django/
.
/iris
- Returns a JSON object with the top 10 classes present in the IRISAPP namespace./interop
- A ping endpoint to test the interoperability framework of IRIS./api/patients
- A list endpoint for a Patient object./api/patients/<pk></pk>
- A retrieve endpoint for a Patient object./api/genomes/<pk>
- A retrieve endpoint for a Genome object./api/pharmacogenomics/get-pharmacogenomics-from-genome/
- API for retrieve pharmacogenomics from an array of genes
The Django application is structured as follows:
app
- Django project folderapp
- Django app folder for configurationsettings.py
- Django settings fileurls.py
- Django URL configuration file to connect the views to the URLswsgi.py
- Django WSGI fileasgi.py
- Django ASGI file
community
- Django app folder for the community app, crud on Post, Comment, Patient, Genome and Pharmacogenomics objectsmodels.py
- Django models file for the Post, Comment, Patient, Genome and Pharmacogenomics objectsviews.py
- Django views file to access the Post, Comment, Patient, Genome and Pharmacogenomics objectsserializers.py
- Django serializers file for the Post, Comment, Patient, Genome and Pharmacogenomics objectsadmin.py
- Django admin file add crud to the admin interfacemigrations
- Django migrations folder to build the databasefixtures
- Django fixtures folder demo data
sqloniris
- Django app folder for the SQL on IRIS appviews.py
- Django views file to query the IRISAPP namespaceapps.py
- Django app configuration file
interop
- Django app folder for the interoperability appviews.py
- Django views file to test the interoperability frameworkapps.py
- Django app configuration file
manage.py
- Django management file
To run the Django application in a standalone mode, we can use the following command:
cd /irisdev/app/app
python3 manage.py runserver 0.0.0.0:8001
This will run the Django application on the default port 8001
.
NB : You must be inside of the container to run this command.
NOTE: This projects starts the Django server by default for easy debug. (You don't have the rebuild the image when you make changes to the Django code)
docker exec -it iris-django-template-iris-1 bash
Be in DEBUG
mode make multiple calls to the application, and the changes will be reflected in the application.
You can access the IRIS Management Portal by going to http://localhost:53795/csp/sys/UtilHome.csp
.
For this you need to have IRIS installed on your machine.
Next you need to create a namespace named IRISAPP
.
Install the requirements.
# Move to the app directory
cd /irisdev/app/app
# python manage.py flush --no-input
python3 manage.py migrate
# create superuser
export DJANGO_SUPERUSER_PASSWORD=SYS
python3 manage.py createsuperuser --no-input --username SuperUser --email [email protected]
# load demo data
python3 manage.py loaddata community/fixtures/demo.json
# collect static files
python3 manage.py collectstatic --no-input --clear
# init iop
iop --init
# load production
iop -m /irisdev/app/app/interop/settings.py
# start production
iop --start Python.Production
To serve the static files in the Django application, we can use the following command:
cd /irisdev/app
python3 manage.py collectstatic
This will collect the static files from the Django application and serve them in the /irisdev/app/static
directory.
To publish the static files in IRIS, configure the Security->Applications->Web Applications
section.