Skip to main content

A re-useable Django app for automatically building a REST API based on models.

Project description

AutoREST

TravisCI PyPI Coveralls Documentation Status Code Style

Documentation: https://django-autorest.readthedocs.io

Source: https://github.com/gregschmit/django-autorest

PyPI: https://pypi.org/project/django-autorest/

AutoREST is a reusable Django app for building REST APIs from model definitions and (optionally) admin.py definitions.

The Problem: Building APIs for models is boring.

The Solution: This app builds them for you, optionally using your AdminSite as a guide, and you can just focus on the custom stuff.

How to Use

$ pip install django-autorest

Include autorest in your INSTALLED_APPS.

Settings

  • AUTOREST_ADMIN_SITE (default 'django.contrib.admin.site'): This is an import string to the admin site where autorest can get hints on how the API should be configured (e.g., list display fields, edit fields, readonly fields, etc). To disable this feature entirely, just set this to False.

  • AUTOREST_DEFAULT_USE_ADMIN_SITE (default False): Whether the default model functionality should be to get config hints from admin.py.

  • AUTOREST_DEFAULT_ENABLE (default: True): Whether API ViewSets/URLs should be built for models which don’t have an explicit entry in the AUTOREST_CONFIG. If this option is False, then only models defined in the AUTOREST_CONFIG will have URLs generated for them.

  • AUTOREST_CONFIG default:

{
    'auth': {
        'User': {
            'viewset': 'autorest.sample_user_viewset.UserViewSet',
        },
    },
}

AUTOREST_CONFIG Options:

  • use_admin_site: Whether to use the admin site to build the API.

  • serializer: An import string to a serializer instance. (Note: if you would use multiple serializers for different actions like list/detail, then you can use drf-action-serializer) to configure a single serializer that supports per-action field configuration.)

  • viewset: An import string to a full viewset for this model.

Contributing

Submit a pull request if you would like to contribute. You must only contribute code that you have authored or otherwise hold the copyright to, and you must make any contributions to this project available under the MIT license.

Development

AutoREST comes with a settings.py file, allowing it to run as a standalone project.

$ git clone https://github.com/gregschmit/django-autorest

Then you can go into the django-autorest directory and do the initial migrations and run the server (you may need to type python3 rather than python):

$ cd django-autorest
$ python manage.py migrate
$ python manage.py createsuperuser
...
$ python manage.py runserver

Then you can see the api at http://127.0.0.1:8000/api/.

Project details


Download files

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

Source Distribution

django-autorest-1.0.0.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

django_autorest-1.0.0-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file django-autorest-1.0.0.tar.gz.

File metadata

  • Download URL: django-autorest-1.0.0.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for django-autorest-1.0.0.tar.gz
Algorithm Hash digest
SHA256 cf71b701c29b3c1ea5557a0f29cbe48a170d243a1980aafc1996632edfd51b4a
MD5 32d5cc24219c0c2416901e96b1c722c5
BLAKE2b-256 09a8cceef896267a42c449918215df8d0f722abf13704ae845c580950c81b6c8

See more details on using hashes here.

Provenance

File details

Details for the file django_autorest-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: django_autorest-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 12.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for django_autorest-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d598c7f8b12f9ab278d532bc0cb55cd4d4272159ebff6c7e62ab86ecdf6b4517
MD5 691b960074e5885893aecdda2775dbf8
BLAKE2b-256 f2b919cd0dc8801d838d9c6161ccabbe8c9be85ce2094be497f53418a9829678

See more details on using hashes here.

Provenance

Supported by

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