{"id":17236036,"url":"https://github.com/hnarayanan/django-extensible-models","last_synced_at":"2026-04-11T08:07:14.847Z","repository":{"id":149732824,"uuid":"579956232","full_name":"hnarayanan/django-extensible-models","owner":"hnarayanan","description":"A robust framework for dynamically extending Django models at runtime","archived":false,"fork":false,"pushed_at":"2024-07-23T16:25:45.000Z","size":130,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-23T01:14:22.169Z","etag":null,"topics":["django","django-rest-framework","dynamic-fields","enterprise","extensible","jsonschema"],"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/hnarayanan.png","metadata":{"files":{"readme":"README.org","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":"2022-12-19T11:11:08.000Z","updated_at":"2024-09-25T14:44:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"56a8fbad-39c9-4875-82a4-af6d3e9b7ca4","html_url":"https://github.com/hnarayanan/django-extensible-models","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hnarayanan/django-extensible-models","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hnarayanan%2Fdjango-extensible-models","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hnarayanan%2Fdjango-extensible-models/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hnarayanan%2Fdjango-extensible-models/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hnarayanan%2Fdjango-extensible-models/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hnarayanan","download_url":"https://codeload.github.com/hnarayanan/django-extensible-models/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hnarayanan%2Fdjango-extensible-models/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31673093,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-10T17:19:37.612Z","status":"online","status_checked_at":"2026-04-11T02:00:05.776Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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","dynamic-fields","enterprise","extensible","jsonschema"],"created_at":"2024-10-15T05:35:14.511Z","updated_at":"2026-04-11T08:07:14.816Z","avatar_url":"https://github.com/hnarayanan.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"* Django Extensible Models\n** What is it?\n\nDjango Extensible Models is a robust framework for dynamically\nextending Django models at runtime. It uses JSONFields for flexible\ndata storage, with JSONSchema validation ensuring data integrity. It\nseamlessly integrates with Django's ORM while enabling multi-tenant\nschema variations.\n\n** Why is it?\n\nDjango offers a really robust model system that functions as a great\ninterface to store and retrieve data related to your app. Models in\nDjango are backed by tables in a relational database. While this is\nreally good for correctness, it is quite rigid in terms of the shape\nof data that is stored. Sometimes, you run into use-cases that demand\na bit more dynamism during the running of your Django app.\n\nLet's take a concrete example. You have an existing Django SaaS app\nthat's launched to many happy customers. They are happy, but each\ncustomer feels that if they could store /just a little bit more custom\ndata/ as part of their usage of your app, their workflows would be\nmuch smoother. So they ask you to add what they want. The trouble is,\neach customer is interested in augmenting their data in different\nways. You diligently add the first customer's fields. And then\nanother's. And then even more. And before you know it, things get\nreally messy.\n\nSolving this problem is the point of this project. Instead of\nindividually catering to each of their requests, /Django Extensible\nModels/ offers you a general extension mechanism that allows your models\nto grow with your customers' needs.\n\n* Features\n** DONE It's easy to incrementally add this to your app\n\nWith a relatively small change to your existing model code (see\n[[#installation][Installation]] and [[#usage][Usage]]), you now have a Django model that retains all\nits Django goodness, and can be extended on the fly with additional\nfields at runtime.\n\n** DONE Formal schema for extended fields\n\nWe don't just stuff the extra data for these additional fields into a\n~JSONField~ and call it a day,[fn::What sort of operation do you think\nthis is?] we allow you to define a proper schema for this data (using\n[[https://jsonschema.net][JSON Schema]]).\n\n** DONE Different extended schema for different groups of objects\n\nIt wouldn't make much sense to apply the same extension schema to all\nobjects of your model,[fn::You could just update the Python model code\nof your app instead!] so Django Extensible Models allows you to define\ndifferent extended fields for different sets of objects.\n\nWe also allow you to extended individual objects in unique ways if\nthat is what you need.\n\n** DONE Strong validation of data for these extended fields\n\nWith a good schema defined, it is easy to validate that incoming data\nfor your extended fields match your expectations before storing it in\nthe database.\n\n** TODO Ability to query these fields using an ORM-friendly syntax\n\nThe data for your extended fields is not simply stored in a messy,\nimpenetrable blob. It is stored in a structured [[https://docs.djangoproject.com/en/dev/ref/models/fields/#jsonfield][JSONField]] that can be\nqueried in a systematic way using standard Django syntax.\n\n** TODO Dynamically generated forms for these extended fields in the Django Admin interface\n** TODO Dynamic extensions for these fields in Django Model Forms (and Crispy Forms)\n** TODO Dynamic extensions for these fields in for Django Rest Framework\n** TODO Dynamic extensions for these fields in Django (Rest Framework) Filters\n** TODO Migrations between versions of your extended schema!\n\nTaken together, you should be able to use your extended fields much\nlike how you use your native Django model fields. And this is just\ncool.\n\n* Installation\n:PROPERTIES:\n:CUSTOM_ID: installation\n:END:\n#+BEGIN_SRC shell\npip install django-extensible-models\n#+END_SRC\n\n#+BEGIN_SRC python\n# settings.py\nINSTALLED_APPS = [\n    # ...\n    \"extensible_models\",\n    # ...\n]\n\nEXTENSIBLE_MODELS_TENANT_MODEL = \"your_app.YourTenantModel\"\nEXTENSIBLE_MODELS_TENANT_FIELD = \"your_tenant_field_name\"\n#+END_SRC\n* Usage\n:PROPERTIES:\n:CUSTOM_ID: usage\n:END:\n\n#+BEGIN_SRC python\n# models.py\nfrom django.db import models\nfrom extensible_models.models import ExtensibleModelMixin\n\n\nclass ExampleModel(ExtensibleModelMixin, models.Model):\n\n    ...\n#+END_SRC\n\n#+BEGIN_SRC python\n# admin.py\nfrom django.contrib import admin\n\nfrom extensible_models.admin import ExtensibleModelAdminMixin\n\n\nclass ExampleModelAdmin(ExtensibleModelAdminMixin, admin.ModelAdmin):\n\n    # Leave all your existing configuration as is!\n#+END_SRC\n* Copyright and License\n\nCopyright (c) 2022-2024 [[https://harishnarayanan.org][Harish Narayanan]]\n\nThis code is licenced under the MIT Licence. See [[https://github.com/hnarayanan/django-extensible-models-experiment/blob/main/LICENSE][LICENSE]] for the full\ntext of this licence.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhnarayanan%2Fdjango-extensible-models","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhnarayanan%2Fdjango-extensible-models","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhnarayanan%2Fdjango-extensible-models/lists"}