Get Autogenerated Serializers and APi End Points
Project description
Autogenerated Api
Get Autogenerated Serializers and API EndPoints
Installing autogenerated-api
autogenerated-api built for django.
PyPi, install using PIP:
pip install autogenerated_api
Customizable Files in Apps
django_app architecture looks like
- appp_name
- __init__.py
- models.py
- serializers.py
- filters.py
- tests.py
- views.py
serilizers.py
from .models import ModelName
from autogenerated_api.serializers import DeadlySerializerFactory
ModelNameDeadlySerializer = DeadlySerializerFactory(modelName)
filters.py
from .models import ModelName
from autogenerated_api.autogeneration import make_model_filter
ModelNameFilter = make_model_filter(ModelName)
views.py
import app_name.models
import app_name.serializers
import app_name.filters
from autogenerated_api.autogeneration import make_all_viewsets
make_all_viewsets(__name__)
Create a new file api_urls.py in main project folder.
Main project folder Architecture
- main_proj_name
- __init__.py
- settings.py
- urls.py
- wsgi.py
- api_urls.py
Add below codes in api_urls.py file.
from django.conf.urls import url,include
import app_name.views
from autogenerated_api import autogenerated_urls
urlpatterns = autogenerated_urls.urlpatterns
urlpatterns += []
Adding to URLs
Add the Below urls.py
urlpatterns = [
url(r'^api/', include('project_name.api_urls', namespace='api'),),
]
Customizable Fields in Settings.
AUTOGENERATE_APPS = ["app_name"]
Finally, you will get autogenerated seraializers and end points.
- Autogenerated End Points
- `/api/model_name_in_lower/` : list out all the model_instance
- `/api/model_name_in_lower/<instance_id>` : you will get detail of instance of given id
Why use autogenerated_api?
Usually , people have to create a serializers for each and every models of an app. In most of the cases , while creating a mdelserializer we have to write same amount of code.
To get the list of model instance , we have to write an api end points , like ListAPiView and for getting the detail of each record , we implement DetailAPIView or RetrieveApiView.
Now , we don't have to create these APi-end points and get worry about the serailizers . This module will take care of the rest.
Coming
Module with more functionality and autogenerated end points.
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 Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file autogenerated_api-1.1.7-py2.py3-none-any.whl.
File metadata
- Download URL: autogenerated_api-1.1.7-py2.py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.19.1 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.7.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1caef57822d16df904ecd6c5de3fc03ffe6a263c8a70af6c19f42c1c7a257e02
|
|
| MD5 |
2cc7c2064b5ccc268b12b74fc0e22ed8
|
|
| BLAKE2b-256 |
7a11a68b6a8716b4280b771ddb780d2f10a68e2a19c451ec7f05363d7b63c6d7
|