Rest Framework Factory (DRFF)
A factory for creating Django Rest Framework APIs
Documentation: https://rest-framework-factory.readthedocs.io.
Features
Create a DRF API painlessly, without needing to repeat boilerplate code
Installation
pip install rest_framework_factory
Requirements
A Django project with at least one app’ from which you wish to build an DRF API included in INSTALLED_APPS, and with at least one model defined in models.py
How it Works
The Factory works because a model itself contains all the information required in order to generate an API for it, including a Serializer, a Viewset, URL(s) and other optional (e.g. Forms, Filters) content
Template files contain variable placeholders referencing the name and attributes of a model
TODOs
WEB UI interface to generate factory apis interactively
Configuration files (YML?) to allow fine-grained control of the factory API, e.g. by including/excluding individual models and/or fields, setting allowed methods, etc.
Swagger
Sphinx
Usage
Basic Usage - Manual Creation
It is not necessary to add rest_framework_factory to INSTALLED_APPS
One common use case is to build a factory using all the models defined in an app:
from rest_framework_factory import factory drff = factory.Factory() drff.build_from_app('my_app') content = drff.apis['app']['my_app'] with open('/tmp/drff_api.py')), 'w') as f: f.write(data)Once the factory file is built, it should be placed into the apps’ folder, added to INSTALLED_APPS, and have its urls wired into the project:
mkdir my_app/drff; touch my_app/drff/__init__.py; cp /tmp/drff_api.py ./my_app/drff/api.py
settings.py:
INSTALLED_APPS += 'my_app.drff'
urls.py:
from my_app.drff.api import urlpatterns as drff_urls urlpatterns += drff_urls
Using the Factory UI
TODO
Scan all the apps, the models therein, and their fields
Build forms for each model/app
Toggle desired models/fields on-off
Select serializer type (ie ModelSerializer vs ReadOnlyModelSerializer
Select allowed API endpoint methos (ie GET, POST)
Configuring the factory via YML
TODO
Initiallize: Scan all apps, the models therein, and their fields; write structure to file
Manually edit file, comment out undesired fields and models, change permissions, etc
Implement: Read yml file, generate factory
Credits
Package created with Cookiecutter.
History
0.1.0 (2019-01-22)
First release on PyPI.
Metadata
Release files for rest-framework-factory 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| rest_framework_factory-0.2.1.tar.gz | 16.4 kB | Without provenance | Details |
Release files / rest_framework_factory-0.2.1.tar.gz
| Download URL | rest_framework_factory-0.2.1.tar.gz |
|---|---|
| Size | 16.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1c31ef6a245fcc2f0b71b8551bd7f13976f620eb5a164c4059d4dc77a3bc4ed6
|
|
BLAKE2b-256 checksum How to use checksums |
510f58dd35f6f3340db4cfe22b132751cfdb8299cc5575eaf5806b95d5946a2f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.6
|
Security for rest-framework-factory 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.