Skip to main content

Django Dynamic API over DRF

Project description

Django Dynamic API

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



For a complete set of features and long-term support, check out Dynamic Django, a powerful starter that incorporates:

  • Dynamic DataTables: using a single line of configuration, the data saved in any table is automatically managed
  • Dynamic API: any model can become a secure API Endpoint using DRF
  • Dynamic Charts: extract relevant charts without coding all major types are supported
  • CSV Loader: translate CSV files into Django Models and (optional) load the information
  • Powerful CLI Tools for the GIT interface, configuration editing, updating the configuration and database (create models, migrate DB)

Dynamic API Features

  • 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 App-Generator

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-dynamic-api-1.0.5.tar.gz (6.5 kB view details)

Uploaded Source

File details

Details for the file django-dynamic-api-1.0.5.tar.gz.

File metadata

  • Download URL: django-dynamic-api-1.0.5.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for django-dynamic-api-1.0.5.tar.gz
Algorithm Hash digest
SHA256 41b6da190c4b2667250bd763f90e7a0ee55a7e32a1954743b984975ae0555d76
MD5 80e47efb2b4cceba7a59675689c3cee2
BLAKE2b-256 925cfdad181fbf732a5f7d894efd116a68243004f0c49baf1c79306264ad7180

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page