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 AppSeed.
Dynamic API Features
API engine
provided byDRF
Minimal Configuration
(single line in config for each model)Handles any model
defined across the project
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
incore/settings.py
(API_GENERATOR 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 byDRF
$ 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 # <-- NEW: 'include` directive added
urlpatterns = [
path("admin/", admin.site.urls),
path('', include('django_dyn_api.urls')), # <-- NEW: API routing rules
]
Step #6 -
Update routing
, includeDRF
JWT authentication
from django.contrib import admin
from rest_framework.authtoken.views import obtain_auth_token # <-- NEW
urlpatterns = [
path("admin/", admin.site.urls),
path('', include('django_dyn_api.urls')), # <-- Added in the previous step
path('login/jwt/', view=obtain_auth_token), # <-- NEW
]
Step #7 -
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 byhttp://localhost:8000/login/jwt/
route (the user should exist).
Links & resources
- DRF - HOMEpage
- More Developer Tools provided by
AppSeed
- Ask for Support via
Email
&Discord
Django Dynamic API - Open-source library provided by AppSeed
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file django-dynamic-api-1.0.0.tar.gz
.
File metadata
- Download URL: django-dynamic-api-1.0.0.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a0ef6831614e43d56ffac91a45ab2ba5ec01ab8ceacf9fd4beedeeae54421666 |
|
MD5 | 1e7d51fd15c6e15294c6e31cbecff02e |
|
BLAKE2b-256 | 19d4dc6f810cd668353f7a853401fd587cbb81328e3c5a9bf8d07b9a482c6c93 |