Giter VIP home page Giter VIP logo

django-dynamic-api's Introduction

Simple tool that Generates Secure APIs on top of DRF with minimum effort - actively supported by AppSeed.


Dynamic API Features - see video presentation

  • API engine provided by DRF
  • Minimal Configuration (single line in config for each model)
  • Handles any model defined across the project

Django Dynamic API - DRF Interface (open-source tool).


How to use it


Step #1 - Install the package

$ pip install django-dynamic-api
// OR
$ pip install git+https://github.com/app-generator/django-dynamic-api.git

Step #2 - Update Configuration, include the new APPs

INSTALLED_APPS = [
    'django_dyn_api',            # Django Dynamic API  # <-- NEW
    'rest_framework',            # Include DRF         # <-- NEW 
    'rest_framework.authtoken',  # Include DRF Auth    # <-- NEW   
]

Step #3 - Register the model in core/settings.py (DYNAMIC_API section)

This sample code assumes that app1 exists and model Book is defined and migrated.

DYNAMIC_API = {
    # pattern: 
    # API_SLUG -> Import_PATH 
    'books'  : "app1.models.Book",
}

REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': [
        'rest_framework.authentication.SessionAuthentication',
        'rest_framework.authentication.TokenAuthentication',
    ],
}

Step #4 - Migrate DB and create the tables used by DRF

$ python manage.py makemigrations
$ python manage.py migrate

Step #5 - Update routing, include APIs

from django.contrib import admin
from django.urls import path, include                        # <-- UPD: 'include` directive
from rest_framework.authtoken.views import obtain_auth_token # <-- NEW

urlpatterns = [
    path("admin/", admin.site.urls),
    path('', include('django_dyn_api.urls')),     # <-- NEW
    path('login/jwt/', view=obtain_auth_token),   # <-- NEW
]    

Step #6 - Use API

If the managed model is Books, the API interface is /api/books/ and all CRUD methods are available.

Note: for mutating requests, the JWT Token is provided by http://localhost:8000/login/jwt/ route (the user should exist).


Django API Generator - POSTMAN Interface (open-source tool).


Links & resources



Django Dynamic API - Open-source library provided by AppSeed

django-dynamic-api's People

Contributors

app-generator avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.