{"id":26448491,"url":"https://github.com/iashraful/fast-drf","last_synced_at":"2025-03-18T14:34:42.127Z","repository":{"id":34442453,"uuid":"162113554","full_name":"iashraful/fast-drf","owner":"iashraful","description":"A simple model based API maker written in Python and based on Django and Django REST Framework","archived":false,"fork":false,"pushed_at":"2024-05-29T09:03:00.000Z","size":175,"stargazers_count":22,"open_issues_count":5,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-17T13:18:35.853Z","etag":null,"topics":["api","django","django-rest-framework","fast","python","rest-api"],"latest_commit_sha":null,"homepage":"https://fast-drf.readthedocs.io/en/latest/","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/iashraful.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":"2018-12-17T10:28:22.000Z","updated_at":"2024-12-05T23:38:31.000Z","dependencies_parsed_at":"2023-11-30T04:28:02.378Z","dependency_job_id":"314af172-8643-4d0d-8fc5-1c6c58b47d85","html_url":"https://github.com/iashraful/fast-drf","commit_stats":null,"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iashraful%2Ffast-drf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iashraful%2Ffast-drf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iashraful%2Ffast-drf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iashraful%2Ffast-drf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iashraful","download_url":"https://codeload.github.com/iashraful/fast-drf/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244240930,"owners_count":20421553,"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":["api","django","django-rest-framework","fast","python","rest-api"],"created_at":"2025-03-18T14:34:41.623Z","updated_at":"2025-03-18T14:34:42.122Z","avatar_url":"https://github.com/iashraful.png","language":"Python","readme":"# Fast DRF [![Documentation Status](https://readthedocs.org/projects/fast-drf/badge/?version=latest)](https://fast-drf.readthedocs.io/en/latest/?badge=latest) [![Python packaging](https://github.com/iashraful/fast-drf/actions/workflows/python-package.yml/badge.svg?branch=master)](https://github.com/iashraful/fast-drf/actions/workflows/python-package.yml)\n\u003e Fast DRF is a small library for making API faster with Django and Django REST Framework.\nIt's easy and configurable.\n\n### Full Documentation [here](https://fast-drf.readthedocs.io)\n### Change Log is [here](https://github.com/iashraful/fast-drf/blob/master/CHANGELOG.md)\n\n### Features\n1. Runtime API creation without writing View, Serializer, Url, etc\n2. API versioning by default.\n3. Control fields on each versions\n4. An enhanced filtering support align with Django query filter.\n5. Customizable API URL and API Prefix.\n6. Options for Overriding Viewset, Serializer, Queryset\n7. Query optimization enabled for API with Django's `prefetch_related` and `select_related`  \n8. Full control over project during making automated API. i.e: you can select an Django app to enable for making API.\n\n### Quick Start\n* Install the library inside your  virtualenv by using pip `pip install fast-drf`\n* Add 'rest_framework' to `INSTALLED_APPS`\n* Add fast_drf.router.BasicRouter.get_urls() to the `urlpatterns` in `urls.py`, e.g.\n```python\nfrom django.contrib import admin\nfrom django.urls import path\nfrom fast_drf.router import BasicRouter\n\nurlpatterns = [\n    path('admin/', admin.site.urls),\n] + BasicRouter.get_urls()\n```\n\n* Add config for Fast DRF like following,\n```python\nFAST_DRF_CONFIG = {\n    'DEFAULT_APPLIED_APPS': (\n        'example_app', 'another_app'\n    )\n}\n```\n* Update your every model or if you use base abstract model then it's good and less time you need. Update model like following,\n**Overriding the `expose_api` classmethod is not necessary anymore. If you just inherit the `ExposeApiModelMixin` mixin class then your app will be detect a api url accordingly.**\n```python\nfrom fast_drf.mixins.expose_api_model_mixin import ExposeApiModelMixin\nfrom django.db import models\n\n\nclass MyModel(ExposeApiModelMixin, models.Model):\n    #... All yor fields\n    pass\n    \n    # The following methods are available from model mixin\n    @classmethod\n    def exposed_api(cls, *args, **kwargs):\n        \"\"\"\n        This method holds a bunch of API configs and return like following...\n        {\n            \"api_url\": \"\",  # (NOT REQUIRED)\n\n            # You must use from HTTPVerbsEnum. Like HTTPVerbsEnum.GET.value, HTTPVerbsEnum.POST.value\n            \"allowed_methods\": ['get', 'post', 'put', 'patch', 'delete'], # (NOT REQUIRED)\n\n            # slug_field is application 'put', 'patch', 'delete' these methods\n            \"slug_field\": \"pk\", # (NOT REQUIRED) DEFAULT [PK] (Must be model field, unique or primary key)\n\n            \"queryset\": \"\",  # (NOT REQUIRED) default all\n            \"viewset_class\": \"\",  # (NOT REQUIRED) BaseViewset class\n            \"serializer_class\": \"\",  # (NOT REQUIRED) default BaseEntitySerializer\n            \"permission_classes\": \"\",  # (NOT REQUIRED) default set from settings\n        }\n        :param args:\n        :param kwargs:\n        :return: An empty Dictionary/False OR Full config dictionary.\n        \"\"\"\n        api_configs = {\n            \"api_url\": 'my-model-api',\n        }\n        return api_configs\n\n```\n\n#### Enable multiple API version\nTo achieve this awesomeness rewrite the following method in your model\n```python\n@classmethod\ndef api_version_fields(cls, **kwargs):\n    \"\"\"\n    *** DEFAULT VERSION `v1` ***\n\n    This method will return a dictionary object with version number and fields name. Fields are similar like\n    serializer fields. Or you can say exactly as same as serializer fields.\n    :param kwargs: Currently nothing to receive on kwargs\n    :return: a dictionary object with version number\n    \"\"\"\n    versions = {\n        'v1': ['id', 'name', 'custom_1', 'custom_2'],\n        'v2': ['id', 'name', 'something_else']\n    }\n    return versions\n```\n\n\n#### Append a slash at the end of of API\nSet `APPEND_SLASH = True` at your settings.py\n\n#### API Prefix Change\nSet you API prefix as your own like following.  \n```python\nFAST_DRF_CONFIG = {\n    # ...\n    'DEFAULT_API_PREFIX': 'rest-api'  # Default 'api'\n    # ...\n}\n```\nYour API will look like, `/rest-api/v1/users/`\n\n\n**That's it.** You can also override serializer class and viewset class\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiashraful%2Ffast-drf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiashraful%2Ffast-drf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiashraful%2Ffast-drf/lists"}