{"id":31856680,"url":"https://github.com/eadwincode/django-ninja-extra","last_synced_at":"2026-02-01T07:17:11.960Z","repository":{"id":37046937,"uuid":"377783591","full_name":"eadwinCode/django-ninja-extra","owner":"eadwinCode","description":"Django Ninja Extra - Class-Based Utility and more for Django Ninja(Fast Django REST framework)","archived":false,"fork":false,"pushed_at":"2025-10-06T16:13:18.000Z","size":10313,"stargazers_count":522,"open_issues_count":25,"forks_count":45,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-10-06T18:23:58.872Z","etag":null,"topics":["django","django-ninja","django-rest-framework","django-schema","drf","python","python-inject"],"latest_commit_sha":null,"homepage":"https://eadwincode.github.io/django-ninja-extra/","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/eadwinCode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["eadwinCode"]}},"created_at":"2021-06-17T09:58:17.000Z","updated_at":"2025-10-06T16:13:16.000Z","dependencies_parsed_at":"2023-12-15T01:32:21.817Z","dependency_job_id":"6c9ab8e0-6f72-4967-80f0-38d80bdbddca","html_url":"https://github.com/eadwinCode/django-ninja-extra","commit_stats":{"total_commits":341,"total_committers":8,"mean_commits":42.625,"dds":"0.055718475073313734","last_synced_commit":"388023df3e462e7dfce23a8abbd603e2d1d32cae"},"previous_names":[],"tags_count":55,"template":false,"template_full_name":null,"purl":"pkg:github/eadwinCode/django-ninja-extra","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eadwinCode%2Fdjango-ninja-extra","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eadwinCode%2Fdjango-ninja-extra/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eadwinCode%2Fdjango-ninja-extra/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eadwinCode%2Fdjango-ninja-extra/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eadwinCode","download_url":"https://codeload.github.com/eadwinCode/django-ninja-extra/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eadwinCode%2Fdjango-ninja-extra/sbom","scorecard":{"id":114370,"data":{"date":"2025-08-11","repo":{"name":"github.com/eadwinCode/django-ninja-extra","commit":"761e9577e79b43e5c884793066d2dcba1742f729"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":5.4,"checks":[{"name":"Maintained","score":10,"reason":"12 commit(s) and 7 issue activity found in the last 90 days -- score normalized to 10","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":2,"reason":"Found 3/11 approved changesets -- score normalized to 2","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/publish.yml:1","Warn: no topLevel permission defined: .github/workflows/test.yml:1","Warn: no topLevel permission defined: .github/workflows/test_full.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/eadwinCode/django-ninja-extra/publish.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/eadwinCode/django-ninja-extra/publish.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/publish.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/eadwinCode/django-ninja-extra/publish.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/eadwinCode/django-ninja-extra/test.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/eadwinCode/django-ninja-extra/test.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/test.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/eadwinCode/django-ninja-extra/test.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test_full.yml:41: update your workflow using https://app.stepsecurity.io/secureworkflow/eadwinCode/django-ninja-extra/test_full.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test_full.yml:43: update your workflow using https://app.stepsecurity.io/secureworkflow/eadwinCode/django-ninja-extra/test_full.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test_full.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/eadwinCode/django-ninja-extra/test_full.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test_full.yml:28: update your workflow using https://app.stepsecurity.io/secureworkflow/eadwinCode/django-ninja-extra/test_full.yml/master?enable=pin","Warn: pipCommand not pinned by hash: .github/workflows/publish.yml:19","Warn: pipCommand not pinned by hash: .github/workflows/publish.yml:23","Warn: pipCommand not pinned by hash: .github/workflows/test.yml:20","Warn: pipCommand not pinned by hash: .github/workflows/test_full.yml:33","Warn: pipCommand not pinned by hash: .github/workflows/test_full.yml:35","Warn: pipCommand not pinned by hash: .github/workflows/test_full.yml:48","Info:   0 out of   8 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   2 third-party GitHubAction dependencies pinned","Info:   0 out of   6 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Packaging","score":10,"reason":"packaging workflow detected","details":["Info: Project packages its releases by way of GitHub Actions.: .github/workflows/publish.yml:9"],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 26 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-16T00:27:40.494Z","repository_id":37046937,"created_at":"2025-08-16T00:27:40.495Z","updated_at":"2025-08-16T00:27:40.495Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279011595,"owners_count":26084964,"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","status":"online","status_checked_at":"2025-10-12T02:00:06.719Z","response_time":53,"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-ninja","django-rest-framework","django-schema","drf","python","python-inject"],"created_at":"2025-10-12T14:22:45.861Z","updated_at":"2025-10-12T14:22:46.685Z","avatar_url":"https://github.com/eadwinCode.png","language":"Python","funding_links":["https://github.com/sponsors/eadwinCode"],"categories":[],"sub_categories":[],"readme":"![Test](https://github.com/eadwinCode/django-ninja-extra/workflows/Test/badge.svg)\n[![PyPI version](https://badge.fury.io/py/django-ninja-extra.svg)](https://badge.fury.io/py/django-ninja-extra)\n[![PyPI version](https://img.shields.io/pypi/v/django-ninja-extra.svg)](https://pypi.python.org/pypi/django-ninja-extra)\n[![PyPI version](https://img.shields.io/pypi/pyversions/django-ninja-extra.svg)](https://pypi.python.org/pypi/django-ninja-extra)\n[![PyPI version](https://img.shields.io/pypi/djversions/django-ninja-extra.svg)](https://pypi.python.org/pypi/django-ninja-extra)\n[![Codecov](https://img.shields.io/codecov/c/gh/eadwinCode/django-ninja-extra)](https://codecov.io/gh/eadwinCode/django-ninja-extra)\n[![Downloads](https://static.pepy.tech/badge/django-ninja-extra)](https://pepy.tech/project/django-ninja-extra)\n\n# Django Ninja Extra\n\nDjango Ninja Extra is a powerful extension for [Django Ninja](https://django-ninja.rest-framework.com) that enhances your Django REST API development experience. It introduces class-based views and advanced features while maintaining the high performance and simplicity of Django Ninja. Whether you're building a small API or a large-scale application, Django Ninja Extra provides the tools you need for clean, maintainable, and efficient API development.\n\n## Features\n\n### Core Features (Inherited from Django Ninja)\n- ⚡ **High Performance**: Built on Pydantic for lightning-fast validation\n- 🔄 **Async Support**: First-class support for async/await operations\n- 📝 **Type Safety**: Comprehensive type hints for better development experience\n- 🎯 **Django Integration**: Seamless integration with Django's ecosystem\n- 📚 **OpenAPI Support**: Automatic API documentation with Swagger/ReDoc\n- 🔒 **API Throttling**: Rate limiting for your API\n\n### Extra Features\n- 🏗️ **Class-Based Controllers**: \n  - Organize related endpoints in controller classes\n  - Inherit common functionality\n  - Share dependencies across endpoints\n\n- 🔒 **Advanced Permission System (Similar to Django Rest Framework)**:\n  - Controller-level permissions\n  - Route-level permission overrides\n  - Custom permission classes\n\n- 💉 **Dependency Injection**:\n  - Built-in support for [Injector](https://injector.readthedocs.io/en/latest/)\n  - Compatible with [django_injector](https://github.com/blubber/django_injector)\n  - Automatic dependency resolution\n\n- 🔧 **Service Layer**:\n  - Injectable services for business logic\n  - Better separation of concerns\n  - Reusable components\n\n## Requirements\n\n- Python \u003e= 3.6\n- Django \u003e= 2.1\n- Pydantic \u003e= 1.6\n- Django-Ninja \u003e= 0.16.1\n\n## Installation\n\n1. Install the package:\n```bash\npip install django-ninja-extra\n```\n\n2. Add to INSTALLED_APPS:\n```python\nINSTALLED_APPS = [\n    ...,\n    'ninja_extra',\n]\n```\n\n## Quick Start Guide\n\n### 1. Basic API Setup\n\nCreate `api.py` in your Django project:\n\n```python\nfrom ninja_extra import NinjaExtraAPI, api_controller, http_get\n\napi = NinjaExtraAPI()\n\n# Function-based endpoint example\n@api.get(\"/hello\", tags=['Basic'])\ndef hello(request, name: str = \"World\"):\n    return {\"message\": f\"Hello, {name}!\"}\n\n# Class-based controller example\n@api_controller('/math', tags=['Math'])\nclass MathController:\n    @http_get('/add')\n    def add(self, a: int, b: int):\n        \"\"\"Add two numbers\"\"\"\n        return {\"result\": a + b}\n\n    @http_get('/multiply')\n    def multiply(self, a: int, b: int):\n        \"\"\"Multiply two numbers\"\"\"\n        return {\"result\": a * b}\n\n# Register your controllers\napi.register_controllers(MathController)\n```\n\n### 2. URL Configuration\n\nIn `urls.py`:\n```python\nfrom django.urls import path\nfrom .api import api\n\nurlpatterns = [\n    path(\"api/\", api.urls),  # This will mount your API at /api/\n]\n```\n\n## Advanced Features\n\n### Authentication and Permissions\n\n```python\nfrom ninja_extra import api_controller, http_get\nfrom ninja_extra.permissions import IsAuthenticated, PermissionBase\n\n# Custom permission\nclass IsAdmin(PermissionBase):\n    def has_permission(self, context):\n        return context.request.user.is_staff\n\n@api_controller('/admin', tags=['Admin'], permissions=[IsAuthenticated, IsAdmin])\nclass AdminController:\n    @http_get('/stats')\n    def get_stats(self):\n        return {\"status\": \"admin only data\"}\n    \n    @http_get('/public', permissions=[])  # Override to make public\n    def public_stats(self):\n        return {\"status\": \"public data\"}\n```\n\n### Dependency Injection with Services\n\n```python\nfrom injector import inject\nfrom ninja_extra import api_controller, http_get\n\n\n# Service class\nclass UserService:\n    def get_user_details(self, user_id: int):\n        return {\"user_id\": user_id, \"status\": \"active\"}\n\n\n# Controller with dependency injection\n@api_controller('/users', tags=['Users'])\nclass UserController:\n    def __init__(self, user_service: UserService):\n        self.user_service = user_service\n\n    @http_get('/{user_id}')\n    def get_user(self, user_id: int):\n        return self.user_service.get_user_details(user_id)\n```\n\n## API Documentation\n\nAccess your API's interactive documentation at `/api/docs`:\n\n![Swagger UI](docs/images/ui_swagger_preview_readme.gif)\n\n## Learning Resources\n\n### Tutorials\n- 📺 [Video: Permissions \u0026 Controllers](https://www.youtube.com/watch?v=yQqig-c2dd4)\n- 💻 [Example: BookStore API](https://github.com/eadwinCode/bookstoreapi)\n- 📚 [Official Documentation](https://eadwincode.github.io/django-ninja-extra/)\n\n### Community and Support\n- 🌟 [GitHub Repository](https://github.com/eadwinCode/django-ninja-extra)\n- 🐛 [Issue Tracker](https://github.com/eadwinCode/django-ninja-extra/issues)\n- 💬 [Discussions](https://github.com/eadwinCode/django-ninja-extra/discussions)\n\n## Contributing\n\nWe welcome contributions! Here's how you can help:\n\n1. Fork the repository\n2. Create a feature branch\n3. Write your changes\n4. Submit a pull request\n\nPlease ensure your code follows our coding standards and includes appropriate tests.\n\n## License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.\n\n## Support the Project\n\n- ⭐ Star the repository\n- 🐛 Report issues\n- 📖 Contribute to documentation\n- 🤝 Submit pull requests\n\n## DEPRECATION NOTICE\n### 0.22.2\nThe `service` attribute in `ModelController` has been changed from a class object to an **instance** object. When creating a custom `ModelService` for a `ModelController`, you have to specify it as `service_type`. \n\nThis is because services are now injected as dependencies during controller instantiation. Service instantiation is delegated to the injector package, so ensure that any additional dependencies required by your `ModelService` are properly registered in the dependency injection container. \n\nFor more details, please refer to the [documentation](https://eadwincode.github.io/django-ninja-extra/api_controller/model_controller/03_model_service/#advanced-service-patterns)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feadwincode%2Fdjango-ninja-extra","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feadwincode%2Fdjango-ninja-extra","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feadwincode%2Fdjango-ninja-extra/lists"}