Django API Generator#
Simple tool that Generates Secure APIs on top of DRF with minimum effort. The library generates the code for every model using a minimal update in configuration. Starters and services that uses the pattern:
Datta Able Django - Free Product that provides the Dynamic API Demo
Django App Generator - the service that include this option (PRO Users)
👉 New to App-Generator? Sign IN with GitHub or Generate Web Apps in no time (free service).
Features#
API engine provided by DRF
Create, Update, Delete requests Secured by JWT Tokens
Minimal Configuration (single line in config for each model)
API code is generated in the API folder (root of the project)
Handles any model defined across the project
- CRUD access logic:
READ is public (all items, get an item by ID)
Mutating requests are reserved for authenticated users

How to use it#
Step #1: Install the package#
$ pip install django-api-generator
// OR
$ pip install git+https://github.com/app-generator/django-api-generator.git
Step #2: Update Configuration#
INSTALLED_APPS = [
'django_api_gen', # Django API GENERATOR # <-- NEW
'rest_framework', # Include DRF # <-- NEW
'rest_framework.authtoken', # Include DRF Auth # <-- NEW
Step #3: - Enable API Generator for Model#
# Syntax: API_SLUG -> Import_PATH
API_GENERATOR = {
'books' : "app1.models.Book",
}
# Used for authentication
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework.authentication.SessionAuthentication',
'rest_framework.authentication.TokenAuthentication',
],
}
Step #4: - Migrate DB#
$ python manage.py makemigrations
$ python manage.py migrate
Step #5: - Generate API#
$ python manage.py generate-api
// OR
$ python manage.py generate-api -f # supress confirmation (forcing mode)
The code is generated under the api folder in the ROOT of the project. At each iteration the API code is overwritten.
Step #6: - Use the generated code#
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("api/", include("api.urls")), # <-- NEW
path('login/jwt/', view=obtain_auth_token), # <-- NEW
Step #7: - Use the API#
If the managed model is Books, the API interface is /api/books/ and all CRUD methods are available.
NOTE: Note: for mutating requests, the JWT Token is provided by http://localhost:8000/login/jwt/ route (the user should exist).

Links#
👉 New to App-Generator? Join our 10k+ Community using GitHub One-Click SignIN.
👉
Download
products and start fast a new project👉 Bootstrap your startUp, MVP or Legacy project with a custom development sprint