Skip to main content

A factory for createing Django Rest Framework APIs

Project description

Rest Framework Factory (DRFF) Documentation Status Updates

A factory for creating Django Rest Framework APIs


  • Create a DRF API painlessly, without needing to repeat boilerplate code


  • pip install rest_framework_factory


  • 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

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


  • 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


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()
    content = drff.apis['app']['my_app']
    with open('/tmp/')), 'w') as f:
  • 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/; cp /tmp/ ./my_app/drff/

      INSTALLED_APPS += 'my_app.drff'

      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



Package created with Cookiecutter.


0.1.0 (2019-01-22)

  • First release on PyPI.

Project details

Download files

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

Files for rest-framework-factory, version 0.2.1
Filename, size File type Python version Upload date Hashes
Filename, size rest_framework_factory-0.2.1.tar.gz (16.4 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page