A simple model based API maker written in Python and based on Django and Django REST Framework

Overview

Fast DRF Documentation Status Python packaging

Fast DRF is a small library for making API faster with Django and Django REST Framework. It's easy and configurable.

Full Documentation here

Change Log is here

Features

  1. Runtime API creation without writing View, Serializer, Url, etc
  2. API versioning by default.
  3. Control fields on each versions
  4. An enhanced filtering support align with Django query filter.
  5. Customizable API URL and API Prefix.
  6. Options for Overriding Viewset, Serializer, Queryset
  7. Query optimization enabled for API with Django's prefetch_related and select_related 8 Full control over project during making automated API. i.e: you can select an Django app to enable for making API.

Quick Start

  • Install the library inside your virtualenv by using pip pip install fast-drf
  • Add config for Fast DRF like following,
FAST_DRF_CONFIG = {
    'DEFAULT_APPLIED_APPS': (
        'example_app', 'another_app'
    )
}
  • Update your every model or if you use base abstract model then it's good and less time you need. Update model like following,
from fast_drf.mixins.expose_api_model_mixin import ExposeApiModelMixin
from django.db import models


class MyModel(ExposeApiModelMixin, models.Model):
    #... All yor fields
    pass
    
    # The following methods are available from model mixin
    @classmethod
    def exposed_api(cls, *args, **kwargs):
        """
        This method holds a bunch of API configs and return like following...
        {
            "api_url": "",  # (REQUIRED)

            # You must use from HTTPVerbsEnum. Like HTTPVerbsEnum.GET.value, HTTPVerbsEnum.POST.value
            "allowed_methods": ['get', 'post', 'put', 'patch', 'delete'], # (NOT REQUIRED)

            # slug_field is application 'put', 'patch', 'delete' these methods
            "slug_field": "pk", # (NOT REQUIRED) DEFAULT [PK] (Must be model field, unique or primary key)

            "queryset": "",  # (NOT REQUIRED) default all
            "viewset_class": "",  # (NOT REQUIRED) BaseViewset class
            "serializer_class": "",  # (NOT REQUIRED) default BaseEntitySerializer
            "permission_classes": "",  # (NOT REQUIRED) default set from settings
        }
        :param args:
        :param kwargs:
        :return: An empty Dictionary/False OR Full config dictionary.
        """
        api_configs = {
            "api_url": 'my-model-api',
        }
        return api_configs

Enable multiple API version

To achieve this awesomeness rewrite the following method in your model

@classmethod
def api_version_fields(cls, **kwargs):
    """
    *** DEFAULT VERSION `v1` ***

    This method will return a dictionary object with version number and fields name. Fields are similar like
    serializer fields. Or you can say exactly as same as serializer fields.
    :param kwargs: Currently nothing to receive on kwargs
    :return: a dictionary object with version number
    """
    versions = {
        'v1': ['id', 'name', 'custom_1', 'custom_2'],
        'v2': ['id', 'name', 'something_else']
    }
    return versions

Append a slash at the end of of API

Set APPEND_SLASH = True at your settings.py

API Prefix Change

Set you API prefix as your own like following.

FAST_DRF_CONFIG = {
    # ...
    'DEFAULT_API_PREFIX': 'rest-api'  # Default 'api'
    # ...
}

Your API will look like, /rest-api/v1/users/

That's it. You can also override serializer class and viewset class

You might also like...
Authentication for Django Rest Framework

Dj-Rest-Auth Drop-in API endpoints for handling authentication securely in Django Rest Framework. Works especially well with SPAs (e.g React, Vue, Ang

JSON Web Token Authentication support for Django REST Framework

REST framework JWT Auth JSON Web Token Authentication support for Django REST Framework Overview This package provides JSON Web Token Authentication s

A JSON Web Token authentication plugin for the Django REST Framework.

Simple JWT Abstract Simple JWT is a JSON Web Token authentication plugin for the Django REST Framework. For full documentation, visit django-rest-fram

A JSON Web Token authentication plugin for the Django REST Framework.

Simple JWT Abstract Simple JWT is a JSON Web Token authentication plugin for the Django REST Framework. For full documentation, visit django-rest-fram

A full Rest-API With Oauth2 and JWT for request & response a JSON file Using FastAPI and SQLAlchemy 🔑
A full Rest-API With Oauth2 and JWT for request & response a JSON file Using FastAPI and SQLAlchemy 🔑

Pexon-Rest-API A full Rest-API for request & response a JSON file, Building a Simple WorkFlow that help you to Request a JSON File Format and Handling

Foundation Auth Proxy is an abstraction on  Foundations' authentication layer and is used to authenticate requests to Atlas's REST API.
Foundation Auth Proxy is an abstraction on Foundations' authentication layer and is used to authenticate requests to Atlas's REST API.

foundations-auth-proxy Setup By default the server runs on http://0.0.0.0:5558. This can be changed via the arguments. Arguments: '-H' or '--host': ho

This app makes it extremely easy to build Django powered SPA's (Single Page App) or Mobile apps exposing all registration and authentication related functionality as CBV's (Class Base View) and REST (JSON)

Welcome to django-rest-auth Repository is unmaintained at the moment (on pause). More info can be found on this issue page: https://github.com/Tivix/d

REST implementation of Django authentication system.
REST implementation of Django authentication system.

djoser REST implementation of Django authentication system. djoser library provides a set of Django Rest Framework views to handle basic actions such

Authentication Module for django rest auth

django-rest-knox Authentication Module for django rest auth Knox provides easy to use authentication for Django REST Framework The aim is to allow for

Comments
  • Detect default api_configs.api_url

    Detect default api_configs.api_url

    Currently it is mandatory to have the following on each model:

        @classmethod
        def exposed_api(cls, *args, **kwargs):
            api_configs = {
                "api_url": 'my-model-api',
            }
            return api_configs
    

    While most production sites will want to customise the urls, it is possible to derive a sensible default from the model class name, making it possible to add models to the API by only adding the mixin. Much faster. And even in production sites, there will be some parts of the API for which the default model name is an acceptable URI name, especially for smaller models.

    opened by jayvdb 6
  • v2.1.1 Release from latest changes

    v2.1.1 Release from latest changes

    2.1.1

    ADDED

    • Added test cases for test app
    • App directory structure has changed. But, no external effect.

    BUG FIXED

    • Import error and some other minor fixes
    opened by iashraful 0
  • Enable filtering with model fields

    Enable filtering with model fields

    Enable filtering with model fields

    Description Currently, We don't have any kind of search or filtering on API. So, We are going to work on it to achieve this feature.

    Tasks to do

    • For now just for model fields
    • Must have option to override on model
    feature 
    opened by iashraful 0
  • Bump djangorestframework from 3.9.0 to 3.9.1

    Bump djangorestframework from 3.9.0 to 3.9.1

    Bumps djangorestframework from 3.9.0 to 3.9.1.

    Release notes

    Sourced from djangorestframework's releases.

    Version 3.9.1

    Change Notes: https://www.django-rest-framework.org/community/release-notes/#39x-series

    Commits
    • 453196e Version 3.9.1 (#6405)
    • 4bb9a3c Fix XSS caused by disabled autoescaping in the default DRF Browsable API view...
    • e3bd4b9 Fix #1811: take limit_choices_to into account with FK (#6371)
    • 9c408b2 Remove reference to deprecated drf-openapi package (#6398)
    • e0ae975 Fix a badly formatted title in docs (#6089)
    • c052a86 compat: (py2) urlparse = urllib.parse (py3) (#6262)
    • a49d744 Fix OpenAPI links (#6382)
    • 0860ef9 Update quickstart to Django 2.0 routing syntax (#6385)
    • 587058e Allow run_validators() to handle non-dict types. (#6365)
    • 0cf18c4 Use Default Version in URLPathVersioning if 'version' Didn't Specified by Cli...
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot ignore this [patch|minor|major] version will close this PR and stop Dependabot creating any more for this minor/major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language
    dependencies 
    opened by dependabot[bot] 0
Releases(2.2.10)
  • 2.2.10(Apr 20, 2022)

  • 2.2.9(Mar 2, 2022)

  • 2.1.3(Apr 22, 2021)

  • 2.1.1(Mar 31, 2021)

    2.1.1

    ADDED

    • Added test cases for test app
    • App directory structure has changed. But, no external effect.

    BUG FIXED

    • Import error and some other minor fixes
    Source code(tar.gz)
    Source code(zip)
  • 2.1.0(Mar 20, 2021)

  • 2.0.0(Aug 12, 2020)

    2.0.0

    ADDED

    • Dynamic API filtering with model fields.
    • Support all the django filter on API params. Like: ?search=1&title:icontains=test

    UPDATED

    • Settings config data type updated with default configuration
    Source code(tar.gz)
    Source code(zip)
  • 1.0.10(Jul 19, 2020)

    1.0.10

    ADDED

    • Added Dockerfile and compose file for local dependency

    BUG FIXES

    • Django REST Framework six dependent version upgraded

    UPDATED

    • Updated API prefix and doc
    Source code(tar.gz)
    Source code(zip)
  • 1.0.9(Sep 27, 2019)

  • 1.0.6(Feb 26, 2019)

    UPDATED

    • Django version updated due to stop vulnerability warning

    ADDED

    • Create from two level of json according to API format

    BUG FIXED

    • Fixed permission class empty issue while user is not giving
    • Fixed Serializer list api data property calling issue
    Source code(tar.gz)
    Source code(zip)
  • 1.0.5(Jan 18, 2019)

  • 1.0.4(Jan 6, 2019)

  • 1.0.3(Jan 3, 2019)

    ADDED

    • Details API [PUT, PATCH, DELETE]
    • Allowed method choosing option
    • Only view class or only serializer class can override
    • Added support for view class or viewset or generic view

    UPDATED

    • Nothing

    BUG FIXED

    • Fixed queryset override issue
    • Fixed queryset caching issue
    Source code(tar.gz)
    Source code(zip)
  • 0.1.2(Dec 27, 2018)

  • 0.1.1(Dec 26, 2018)

    ADDED

    • Added utility classes for support
    • Added example app for local testing(Not added in package)

    UPDATED

    • Updated directory structure of app
    • Seperated mixins

    BUG FIXED

    • Fixed wrong queryset bug
    • Added loop iteration improvements
    Source code(tar.gz)
    Source code(zip)
  • 0.0.1(Dec 26, 2018)

    ADDED

    • Model Based api writing
    • Ability to override Serializer, View class, queryset
    • Work on proxy model

    BUG FIXED

    • Nothing as it's initial release
    Source code(tar.gz)
    Source code(zip)
Owner
Mohammad Ashraful Islam
*nix Fan, Open Source Contributor, Problem Solver, Python Lover, JS fan
Mohammad Ashraful Islam
This python package provides a simple password reset strategy for django rest framework

Django Rest Password Reset This python package provides a simple password reset strategy for django rest framework, where users can request password r

Anexia 363 Dec 24, 2022
Django-react-firebase-auth - A web app showcasing OAuth2.0 + OpenID Connect using Firebase, Django-Rest-Framework and React

Demo app to show Django Rest Framework working with Firebase for authentication

Teshank Raut 6 Oct 13, 2022
Django Auth Protection This package logout users from the system by changing the password in Simple JWT REST API.

Django Auth Protection Django Auth Protection This package logout users from the system by changing the password in REST API. Why Django Auth Protecti

Iman Karimi 5 Oct 26, 2022
python-social-auth and oauth2 support for django-rest-framework

Django REST Framework Social OAuth2 This module provides OAuth2 social authentication support for applications in Django REST Framework. The aim of th

null 1k Dec 22, 2022
python-social-auth and oauth2 support for django-rest-framework

Django REST Framework Social OAuth2 This module provides OAuth2 social authentication support for applications in Django REST Framework. The aim of th

null 1k Dec 22, 2022
Django Rest Framework App wih JWT Authentication and other DRF stuff

Django Queries App with JWT authentication, Class Based Views, Serializers, Swagger UI, CI/CD and other cool DRF stuff API Documentaion /swagger - Swa

Rafael Salimov 4 Jan 29, 2022
A JSON Web Token authentication plugin for the Django REST Framework.

Simple JWT Abstract Simple JWT is a JSON Web Token authentication plugin for the Django REST Framework. For full documentation, visit django-rest-fram

Simple JWT 3.3k Jan 1, 2023
Authentication for Django Rest Framework

Dj-Rest-Auth Drop-in API endpoints for handling authentication securely in Django Rest Framework. Works especially well with SPAs (e.g React, Vue, Ang

Michael 1.1k Jan 3, 2023
JSON Web Token Authentication support for Django REST Framework

REST framework JWT Auth Notice This project is currently unmaintained. Check #484 for more details and suggested alternatives. JSON Web Token Authenti

José Padilla 3.2k Dec 31, 2022
An extension of django rest framework, providing a configurable password reset strategy

Django Rest Password Reset This python package provides a simple password reset strategy for django rest framework, where users can request password r

Anexia 363 Dec 24, 2022