Get Autogenerated Serializers and APi End Points
Project description
Autogenerated Api
Get Autogenerated Serializers and API EndPoints
Requirements
- django==1.8.14
- djangorestframework==3.4.2
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
- tests.py
- views.py
serilizers.py
from .models import ModelName
from autogenerated_api.serializers import DeadlySerializerFactory
ModelNameDeadlySerializer = DeadlySerializerFactory(modelName)
views.py
import app_name.models
import app_name.serializers
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('main_proj_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?
Through autogenerated_api
module , you can directly use autogenerated serializers and can also access the fields value of model which are in relation (m2m or foreignkey relationship)
.
To get the list of model instance , we have to write an api end points , like ListAPiView
and for getting the detail of model instance, have to implement DetailAPIView or RetrieveApiView
end points.
Now , You 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 more 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
Hashes for autogenerated_api-1.1.13-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 11250638db0c4a7ebf9b3f8db5417fa928dfc60531f5064a5fe2571b9b8ab9ee |
|
MD5 | f9273435e020d63eaebd73e6dbe9befb |
|
BLAKE2b-256 | ba3a309e671b3fe9364fd6d7fef159fafcbccb525617a3726c3fcb2b3d6dd664 |