{"id":13625508,"url":"https://github.com/pycasbin/django-orm-adapter","last_synced_at":"2025-04-09T19:17:02.765Z","repository":{"id":56763323,"uuid":"236434161","full_name":"pycasbin/django-orm-adapter","owner":"pycasbin","description":"Django ORM Adapter for PyCasbin","archived":false,"fork":false,"pushed_at":"2024-10-28T14:46:44.000Z","size":62,"stargazers_count":30,"open_issues_count":1,"forks_count":19,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-09T19:16:57.693Z","etag":null,"topics":["access-control","adapter","authorization","casbin","django","django-orm","orm","pycasbin","storage-driver"],"latest_commit_sha":null,"homepage":"https://github.com/casbin/pycasbin","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pycasbin.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2020-01-27T06:46:14.000Z","updated_at":"2024-10-28T14:46:43.000Z","dependencies_parsed_at":"2023-01-31T06:00:16.004Z","dependency_job_id":"914e9f74-9c59-4ac1-9314-a4a9b6b47d73","html_url":"https://github.com/pycasbin/django-orm-adapter","commit_stats":{"total_commits":37,"total_committers":4,"mean_commits":9.25,"dds":0.3783783783783784,"last_synced_commit":"9cc651366706058502da217a87f97f91fe3fcd6c"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pycasbin%2Fdjango-orm-adapter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pycasbin%2Fdjango-orm-adapter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pycasbin%2Fdjango-orm-adapter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pycasbin%2Fdjango-orm-adapter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pycasbin","download_url":"https://codeload.github.com/pycasbin/django-orm-adapter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248094988,"owners_count":21046770,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["access-control","adapter","authorization","casbin","django","django-orm","orm","pycasbin","storage-driver"],"created_at":"2024-08-01T21:01:56.961Z","updated_at":"2025-04-09T19:17:02.739Z","avatar_url":"https://github.com/pycasbin.png","language":"Python","readme":"# Django ORM Adapter for PyCasbin\n\n[![GitHub Action](https://github.com/pycasbin/django-orm-adapter/workflows/build/badge.svg?branch=master)](https://github.com/pycasbin/django-orm-adapter/actions)\n[![Coverage Status](https://coveralls.io/repos/github/pycasbin/django-orm-adapter/badge.svg)](https://coveralls.io/github/pycasbin/django-orm-adapter)\n[![Version](https://img.shields.io/pypi/v/casbin-django-orm-adapter.svg)](https://pypi.org/project/casbin-django-orm-adapter/)\n[![PyPI - Wheel](https://img.shields.io/pypi/wheel/casbin-django-orm-adapter.svg)](https://pypi.org/project/casbin-django-orm-adapter/)\n[![Pyversions](https://img.shields.io/pypi/pyversions/casbin-django-orm-adapter.svg)](https://pypi.org/project/casbin-django-orm-adapter/)\n[![Download](https://img.shields.io/pypi/dm/casbin-django-orm-adapter.svg)](https://pypi.org/project/casbin-django-orm-adapter/)\n[![Discord](https://img.shields.io/discord/1022748306096537660?logo=discord\u0026label=discord\u0026color=5865F2)](https://discord.gg/S5UjpzGZjN)\n\nDjango ORM Adapter is the [Django](https://www.djangoproject.com/)'s [ORM](https://docs.djangoproject.com/en/3.0/ref/databases/) adapter for [PyCasbin](https://github.com/pycasbin/django-orm-adapter). With this library, Casbin can load policy from Django ORM supported database or save policy to it.\n\nBased on [Officially Supported Databases](https://docs.djangoproject.com/en/3.0/ref/databases/), The current supported databases are:\n\n- PostgreSQL\n- MariaDB\n- MySQL\n- Oracle\n- SQLite\n- IBM DB2\n- Microsoft SQL Server\n- Firebird\n- ODBC\n\n## Installation\n\n```\npip install casbin-django-orm-adapter\n```\n\nAdd `casbin_adapter.apps.CasbinAdapterConfig` to your `INSTALLED_APPS`\n\n```python\n# settings.py\nBASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))\n\nINSTALLED_APPS = [\n    ...\n    'casbin_adapter.apps.CasbinAdapterConfig',\n    ...\n]\n\nCASBIN_MODEL = os.path.join(BASE_DIR, 'casbin.conf')\n```\n\nTo run schema migration, execute `python manage.py migrate casbin_adapter`\n\n## Simple Example\n\n```python\n# views.py\nfrom casbin_adapter.enforcer import enforcer\n\ndef hello(request):\n    sub = \"alice\"  # the user that wants to access a resource.\n    obj = \"data1\"  # the resource that is going to be accessed.\n    act = \"read\"  # the operation that the user performs on the resource.\n\n    if e.enforce(sub, obj, act):\n        # permit alice to read data1casbin_django_orm_adapter\n        pass\n    else:\n        # deny the request, show an error\n        pass\n```\n\n## Configuration\n\n### `CASBIN_MODEL`\nA string containing the file location of your casbin model.\n\n### `CASBIN_ADAPTER`\nA string containing the adapter import path. Default to the django adapter shipped with this package: `casbin_adapter.adapter.Adapter`\n\n### `CASBIN_ADAPTER_ARGS`\nA tuple of arguments to be passed into the constructor of the adapter specified\nin `CASBIN_ADAPTER`. Refer to adapters to see available arguments. \n\nE.g. if you wish to use the file adapter \nset the adapter to `casbin.persist.adapters.FileAdapter` and use\n`CASBIN_ADAPTER_ARGS = ('path/to/policy_file.csv',)`\n\n### `CASBIN_DB_ALIAS`\nThe database the adapter uses. Default to \"default\".\n\n### `CASBIN_WATCHER`\nWatcher instance to be set as the watcher on the enforcer instance.\n\n### `CASBIN_ROLE_MANAGER`\nRole manager instance to be set as the role manager on the enforcer instance.\n\n\n### Getting Help\n\n- [PyCasbin](https://github.com/casbin/pycasbin)\n\n### License\n\nThis project is licensed under the [Apache 2.0 license](LICENSE).\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpycasbin%2Fdjango-orm-adapter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpycasbin%2Fdjango-orm-adapter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpycasbin%2Fdjango-orm-adapter/lists"}