Skip to main content

Get Autogenerated Serializers and APi End Points

Project description

Autogenerated Api

Get Autogenerated Serializers and API EndPoints

Requirements

- django
- djangorestframework

Released with latest version of Django.

Installing autogenerated-api

autogenerated-api built for django.

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.

import app_name.views
from django.urls import path, re_path , include

from autogenerated_api import autogenerated_urls
urlpatterns = autogenerated_urls.urlpatterns

urlpatterns += []

Adding to URLs

Add the Below urls.py

from django.urls import path, re_path , include

urlpatterns = [
    re_path(r'^api/', include('main_proj_name.api_urls' , 'main_proj_name'), 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 create serializers coresponding to each model and can also access the all fields value of model which are in relation (m2m or foreignkey relationship).

To get the list of model instance , You 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. Just , follow the steps that i mentioned above.

Coming

- Module with more functionality and more autogenerated end points.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

autogenerated_api-1.1.20-py2.py3-none-any.whl (9.2 kB view details)

Uploaded Python 2Python 3

File details

Details for the file autogenerated_api-1.1.20-py2.py3-none-any.whl.

File metadata

  • Download URL: autogenerated_api-1.1.20-py2.py3-none-any.whl
  • Upload date:
  • Size: 9.2 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

Hashes for autogenerated_api-1.1.20-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 002b8c983b666a8aa921564de36519c192c1f9e5e67da03c35a1f193b5853c67
MD5 bfa423d7ca1f6d80ad874eedc49f6834
BLAKE2b-256 21345d7ad9a7a00cace309359b8b30eb64aa6daa8f5869459fd764a9c0f7fc23

See more details on using hashes here.

Supported by

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