{"id":39259519,"url":"https://github.com/grongierisc/iris-django-template","last_synced_at":"2026-01-18T00:25:14.882Z","repository":{"id":246005733,"uuid":"817367322","full_name":"grongierisc/iris-django-template","owner":"grongierisc","description":"Iris python first experience django template","archived":false,"fork":false,"pushed_at":"2024-06-26T07:29:46.000Z","size":306,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-06-26T10:36:22.446Z","etag":null,"topics":["django","django-rest-framework","intersystems-iris","iris"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/grongierisc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-19T14:54:25.000Z","updated_at":"2024-06-26T07:29:50.000Z","dependencies_parsed_at":"2024-06-25T10:30:54.586Z","dependency_job_id":"2612ca5e-eb27-450a-9af5-61195d4706cb","html_url":"https://github.com/grongierisc/iris-django-template","commit_stats":null,"previous_names":["grongierisc/iris-django-template"],"tags_count":0,"template":true,"template_full_name":null,"purl":"pkg:github/grongierisc/iris-django-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grongierisc%2Firis-django-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grongierisc%2Firis-django-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grongierisc%2Firis-django-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grongierisc%2Firis-django-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/grongierisc","download_url":"https://codeload.github.com/grongierisc/iris-django-template/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grongierisc%2Firis-django-template/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28523717,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T23:53:28.710Z","status":"ssl_error","status_checked_at":"2026-01-17T23:52:20.131Z","response_time":85,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["django","django-rest-framework","intersystems-iris","iris"],"created_at":"2026-01-18T00:25:14.254Z","updated_at":"2026-01-18T00:25:14.866Z","avatar_url":"https://github.com/grongierisc.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# iris-django-template\n\n![django_logo](https://www.djangoproject.com/m/img/logos/django-logo-negative.png)\n\n## Description\n\nThis is a template for an Django application that can be deployed in IRIS as an native Web Application.\n\n## Installation\n\n1. Clone the repository\n2. Create a virtual environment\n3. Install the requirements\n4. Run the docker-compose file\n\n```bash\ngit clone\ncd iris-django-template\npython3 -m venv .venv\nsource .venv/bin/activate\npip install -r requirements.txt\ndocker-compose up\n```\n\n## Usage\n\nThe base URL is `http://localhost:53795/django/`.\n\n### Endpoints\n\n- `/iris` - Returns a JSON object with the top 10 classes present in the IRISAPP namespace.\n- `/interop` - A ping endpoint to test the interoperability framework of IRIS.\n- `/api/posts` - A simple CRUD endpoint for a Post object.\n- `/api/comments` - A simple CRUD endpoint for a Comment object.\n\n## How to develop from this template\n\nSee WSGI introduction article: [wsgi-introduction](https://community.intersystems.com/post/wsgi-support-introduction).\n\nTL;DR : You can toggle the `DEBUG` flag in the Security portal to make changes to be reflected in the application as you develop.\n\n## Code presentation\n\nThe Django application is structured as follows:\n\n- `app` - Django project folder\n  - `app` - Django app folder for configuration\n    - `settings.py` - Django settings file\n    - `urls.py` - Django URL configuration file to connect the views to the URLs\n    - `wsgi.py` - Django WSGI file\n    - `asgi.py` - Django ASGI file\n  - `community` - Django app folder for the community app, crud on Post and Comment objects\n    - `models.py` - Django models file for the Post and Comment objects\n    - `views.py` - Django views file to access the Post and Comment objects\n    - `serializers.py` - Django serializers file for the Post and Comment objects\n    - `admin.py` - Django admin file add crud to the admin interface\n    - `migrations` - Django migrations folder to build the database\n    - `fixtures` - Django fixtures folder demo data \n  - `sqloniris` - Django app folder for the SQL on IRIS app\n    - `views.py` - Django views file to query the IRISAPP namespace\n    - `apps.py` - Django app configuration file\n  - `interop` - Django app folder for the interoperability app\n    - `views.py` - Django views file to test the interoperability framework\n    - `apps.py` - Django app configuration file\n  - `manage.py` - Django management file\n\n### `app/settings.py`\n\nThis file contains the Django settings for the application.\n\n```python\n...\n\n# Application definition\n\nINSTALLED_APPS = [\n    'django.contrib.admin',\n    'django.contrib.auth',\n    'django.contrib.contenttypes',\n    'django.contrib.sessions',\n    'django.contrib.messages',\n    'django.contrib.staticfiles',\n    'community',\n    'sqloniris',\n    'interop',\n    'rest_framework'\n]\n\n...\n\nREST_FRAMEWORK = {\n    # Use Django's standard `django.contrib.auth` permissions,\n    # or allow read-only access for unauthenticated users.\n    'DEFAULT_PERMISSION_CLASSES': [\n        'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'\n    ],\n    'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination',\n    'PAGE_SIZE': 20\n}\n\n...\n\nDATABASES = {\n    \"default\": {\n        \"ENGINE\": \"django_iris\",\n        \"EMBEDDED\": True,\n        \"NAMESPACE\": \"IRISAPP\",\n        \"USER\":\"SuperUser\",\n        \"PASSWORD\":\"SYS\",\n    }\n}\n```\n\nFew important settings to note:\n\n- `INSTALLED_APPS` - Contains the list of installed apps in the Django project.\n  - `community` - The Django app for the CRUD operations on the Post and Comment objects.\n  - `sqloniris` - The Django app for the SQL on IRIS operations.\n  - `interop` - The Django app for the interoperability operations.\n  - `rest_framework` - The Django REST framework for the REST API.\n- `REST_FRAMEWORK` - Contains the settings for the Django REST framework.\n  - `DEFAULT_PERMISSION_CLASSES` - Only authenticated users can perform CRUD operations.\n  - `DEFAULT_PAGINATION_CLASS` - The pagination class for the REST API.\n- `DATABASES` - Contains the settings for the IRIS database connection.\n  - Here we are using the `django_iris` engine to connect to the IRIS database.\n\n### `app/urls.py`\n\nThis file contains the URL configuration for the Django application.\n\n```python\nfrom django.contrib import admin\nfrom django.urls import path,include\nfrom rest_framework import routers\nfrom community.views import PostViewSet, CommentViewSet\nfrom sqloniris.views import index\nfrom interop.views import index as interop_index\n\nrouter = routers.DefaultRouter()\nrouter.register(r'posts', PostViewSet)\nrouter.register(r'comments', CommentViewSet)\n\n\nurlpatterns = [\n    path('admin/', admin.site.urls),\n    path('api/', include(router.urls)),\n    path('iris/', index),\n    path('interop/', interop_index)\n]\n```\n\n- `router` - Contains the default router for the REST API.\n- `routeer.register` - Registers the Post and Comment viewsets to the router.\n- `urlpatterns` - Contains the URL patterns for the Django application.\n  - `/admin/` - The Django admin interface.\n  - `/api/` - The REST API for the Post and Comment objects.\n  - `/iris/` - The SQL on IRIS endpoint.\n  - `/interop/` - The interoperability endpoint.\n\n### `app/wsgi.py`\n\nThis file contains the WSGI configuration for the Django application.\n\nThis is the file that we have to provide to IRIS to run the Django application.\n\nIn the `Security-\u003eApplications-\u003eWeb Applications` section, we have to provide the path to this file.\n\n- **Application Name**\n  - `app.wsgi`\n- **Callable Name**\n  - `application`\n- **WSGI App directory**\n  - `/irisdev/app/app`\n\n### `community/models.py`\n\nThis file contains the Django models for the Post and Comment objects.\n\n```python\nfrom django.db import models\n\n# Create your models here.\nclass Post(models.Model):\n    title = models.CharField(max_length=100)\n    content = models.TextField()\n\nclass Comment(models.Model):\n    content = models.TextField()\n    post = models.ForeignKey(Post, on_delete=models.CASCADE, related_name='comments')\n```\n\n- `Post` - The model for the Post object.\n  - `title` - The title of the post.\n  - `content` - The content of the post.\n- `Comment` - The model for the Comment object.\n  - `content` - The content of the comment.\n  - `post` - The foreign key to the Post object.\n  - `related_name` - The related name for the comments.\n\n### `community/seializers.py`\n\nThis file contains the Django serializers for the Post and Comment objects.\n\nUsing the Django REST framework, we can serialize the Django models to JSON objects.\n\n```python\nfrom rest_framework import serializers\nfrom community.models import Post, Comment\n\nclass PostSerializer(serializers.ModelSerializer):\n    class Meta:\n        model = Post\n        fields = ('id', 'title', 'content', 'comments')\n\nclass CommentSerializer(serializers.ModelSerializer):\n    class Meta:\n        model = Comment\n        fields = ('id', 'content', 'post')\n```\n\n- `PostSerializer` - The serializer for the Post object.\n- `CommentSerializer` - The serializer for the Comment object.\n- `fields` - The fields to be serialized.\n\n### `community/views.py`\n\nThis file contains the Django views for the Post and Comment objects.\n\nUsing the Django REST framework, we can create CRUD operations for the Django models.\n\n```python\nfrom django.shortcuts import render\nfrom rest_framework import viewsets\n\n# Import the Post and Comment models\nfrom community.models import Post, Comment\n\n# Import the Post and Comment serializers\nfrom community.serializers import PostSerializer, CommentSerializer\n\n# Create your views here.\nclass PostViewSet(viewsets.ModelViewSet):\n    queryset = Post.objects.all()\n    serializer_class = PostSerializer\n\nclass CommentViewSet(viewsets.ModelViewSet):\n    queryset = Comment.objects.all()\n    serializer_class = CommentSerializer\n```\n\n- `PostViewSet` - The viewset for the Post object.\n- `CommentViewSet` - The viewset for the Comment object.\n- `queryset` - The queryset for the viewset.\n- `serializer_class` - The serializer class for the viewset.\n\n### `sqloniris/views.py`\n\nThis file contains the Django views for the SQL on IRIS operations.\n\n```python\nfrom django.http import JsonResponse\n\nimport iris\n\ndef index(request):\n    query = \"SELECT top 10 * FROM %Dictionary.ClassDefinition\"\n    rs = iris.sql.exec(query)\n    # Convert the result to a list of dictionaries\n    result = []\n    for row in rs:\n        result.append(row)\n    return JsonResponse(result, safe=False)\n```\n\n- `index` - The view for the SQL on IRIS operation.\n- `query` - The SQL query to be executed on the IRIS database.\n- `rs` - The result set from the query.\n- `result` - The list of list from the result set.\n- `JsonResponse` - The JSON response for the view, safe is set to False to allow list of list.\n\n### `interop/views.py`\n\nThis file contains the Django views for the interoperability operations.\n\n```python\nfrom django.http import HttpResponse\n\nfrom iop import Director\n\nbs = Director.create_python_business_service('BS')\n\ndef index(request):\n    result = bs.on_process_input(request)\n    return HttpResponse(result, safe=False)\n```\n\n- `bs` - The business service object created using the `Director` class.\n- `index` - The view for the interoperability operation.\n- `result` - The result from the business service.\n\nNB : we don't use `JsonResponse` to simplify the code, we can use it if we want to return a JSON object.\n\n## Troubleshooting\n\n### How to run the Django application in a standalone mode\n\nTo run the Django application in a standalone mode, we can use the following command:\n\n```bash\ncd /irisdev/app/app\npython3 manage.py runserver 8001\n```\n\nThis will run the Django application on the default port `8001`.\n\n\nNB : You must be inside of the container to run this command.\n\n```bash\ndocker exec -it iris-django-template-iris-1 bash\n```\n\n### Restart the application in IRIS\n\nBe in `DEBUG` mode make multiple calls to the application, and the changes will be reflected in the application.\n\n### How to access the IRIS Management Portal\n\nYou can access the IRIS Management Portal by going to `http://localhost:53795/csp/sys/UtilHome.csp`.\n\n### Run this template locally\n\nFor this you need to have IRIS installed on your machine.\n\nNext you need to create a namespace named `IRISAPP`.\n\nInstall the requirements.\n\n```bash\n# Move to the app directory\ncd /irisdev/app/app\n\n# python manage.py flush --no-input\npython3 manage.py migrate\n# create superuser\nexport DJANGO_SUPERUSER_PASSWORD=SYS\npython3 manage.py createsuperuser --no-input --username SuperUser --email admin@admin.fr\n\n# load demo data\npython3 manage.py loaddata community/fixtures/demo.json\n\n# collect static files\npython3 manage.py collectstatic --no-input --clear\n\n# init iop\niop --init\n\n# load production\niop -m /irisdev/app/app/interop/settings.py\n\n# start production\niop --start Python.Production\n```\n\n### How to serve static files\n\nTo serve the static files in the Django application, we can use the following command:\n\n```bash\ncd /irisdev/app\npython3 manage.py collectstatic\n```\n\nThis will collect the static files from the Django application and serve them in the `/irisdev/app/static` directory.\n\nTo publish the static files in IRIS, configure the `Security-\u003eApplications-\u003eWeb Applications` section.\n\n![web_applications](./misc/static.png)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrongierisc%2Firis-django-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrongierisc%2Firis-django-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrongierisc%2Firis-django-template/lists"}