Article
· Feb 25, 2022 3m read

Welcome Django

With the latest improvements in support for Python in IRIS, and continued work on Python DB-API support by InterSystems. I've implemented IRIS support to the Django project where is Python DB-API is used to work with some other databases.

Let's try a simple application on Django, which stores its data in IRIS.

todo App

That application is available on GitHub, let's clone it

git clone https://github.com/caretdev/django-iris-todo
cd django-iris-todo

And we can build and start it with Docker-compose

docker-compose up -d --build

It will take some some, when IRIS will be started, and Django application will catch it migrate the models there and starts application too, once it's started it will be available by http://localhost:8000/ and you should the the picture like above.

But how it works

To make it work It requires, InterSystems Python DB-API installed, it comes with the latest preview version, so, you will need to have version 2022.1.0.114.0 or above and it's located in instance's folder <INSTALL_DIR>/dev/python/. This file can also be downloaded from this GitHub repo 

pip3 install intersystems_irispython-3.2.0-py3-none-any.whl

Django's IRIS backend is implemented by another project, and which can be installed with pip, and for sure we need django itself, let's install them

pip3 install django django-iris

Another way to install required packages in Python is to use requirements.txt file

pip3 install -r requirements.txt

While that file contains, this lines

https://raw.githubusercontent.com/intersystems-community/iris-driver-distribution/main/intersystems_irispython-3.2.0-py3-none-any.whl
Django~=4.0.2
django-iris~=0.1.5

Let's connect our Django application to the IRIS, open file todoApp/settings.py

DATABASES defines connections settings to the database

ENGINE should be django_IRIS

NAME should point to Namespace in IRIS

Just change it to something, where it can connect. For instance

DATABASES = {
    'default': {
        'ENGINE': 'django_iris',
        'NAME': 'DJANGOTODO',
        'HOST': 'localhost',
        'PORT': 1972,
        'USER': '_SYSTEM',
        'PASSWORD': 'SYS',
    }
}

And start migration

python3 manage.py migrate

No errors, all tables on IRIS side is created

And we are ready to start our application

python3 manage.py runserver

Django comes with an admin panel

python3 manage.py createsuperuser

And admin panel is available by link http://localhost:8000/admin/

And how it stored in IRIS

 

There are still some scope of work needs to be done to have a full support. Work still in progress for Python DB-API driver from InterSystems, and also for this django-iris project.

Be aware, that it may not work so smooth on Community Edition version, due to the way how Django connects to the database, it may use all the licenses very quickly

If you like the project, and its future impact of using IRIS please vote on OpenExchange contest

Discussion (3)2
Log in or sign up to continue

And I have one more demo project, based on Realworld application, I found on GitHub

What I did, is just forked some project, switched it to using IRIS, by configuring its settings, added requirements, wrapped it in the container with IRIS, and that's mostly it.

Look at the repo https://github.com/caretdev/django-iris-realworld

For this project, I've used a non-CE version of IRIS, so, you will need an iris.key, placed in home directory to start it