Welcome Django
Tags: python, framework, coding, beginners
Published: 2023-07-15 21:15:56

With the latest improvements in support for Python in IRIS, and continued work on [Python DB-API](https://docs.intersystems.com/irisforhealth20221/csp/docbook/DocBook.UI.Page.cls?KEY=BTPI_pyapi) 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.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pwgi1hb5gen8n3928pwe.png)
That application is available on 

[GitHub](https://github.com/caretdev/django-iris-todo), 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 `&lt;INSTALL_DIR>/dev/python/`. This file can also be downloaded from [this GitHub repo](https://github.com/intersystems-community/iris-driver-distribution) 

    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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jlih6hc2ntasaw8xuwbx.png)

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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ptphxuqh0fwisq13f0mj.png)

No errors, all tables on IRIS side is created

And we are ready to start our application

    python3 manage.py runserver


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/srgjdvse92elcdztudn0.png)

Django comes with an admin panel

    python3 manage.py createsuperuser


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z52zegefhvvpkhi5d4uv.png)

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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g5gns1vaa87t9rle105c.png)

And how it stored in IRIS


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/418k878m944efb9c6ykk.png)

 

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](https://openexchange.intersystems.com/contest/current)