Skip to main content

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

This version

1.0.0

Download files

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

Files for drf-autoview, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size drf-autoview-1.0.0.tar.gz (2.3 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page