Django drf api generator
Project description
django-drf-autoview
Expose CRUD DRF compatible api's for any django model with one line. This patten can be used to quickly bootstrap an api server app based on django DRF.
Example
# Add below snippet in api.py of the django app
from drf_autoview.api import get_api_views_with_all_fields_readonly
api_views = get_api_views_with_all_fields_readonly([
models.DemoModel,
])
# Add below snippet in site/api.py
from drf_autoview.api import register_with_router
def get_router():
_router = routers.DefaultRouter()
_apps = filter(lambda x: '<appName>' in x[1].name, apps.app_configs.items())
for _app_name, _app_obj in _apps:
if module_has_submodule(_app_obj.module, 'api'):
api = import_module('{0}.api'.format(_app_obj.module.__name__))
register_with_router(_router, api.api_views)
return _router
router = get_router()
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
drf-autoview-1.0.0.tar.gz
(2.3 kB
view details)
File details
Details for the file drf-autoview-1.0.0.tar.gz
.
File metadata
- Download URL: drf-autoview-1.0.0.tar.gz
- Upload date:
- Size: 2.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7fe38a9fb5c15745a604c9671de850a9a595624749f5803fa37c77f27189779c |
|
MD5 | 4094beff5c1cde7d6ff557e6cc3fe339 |
|
BLAKE2b-256 | f6c5583d9b725bf5d7eab66be7ccad0082ffb4bb778e7870dd54093185e7e7a1 |