Invisi / django-rest-framework-datatables

Seamless integration between Django REST framework and Datatables.

Home Page:http://django-rest-framework-datatables.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

django-rest-framework-datatables

Travis build codecov-image Documentation Status Pypi version Python versions

Overview

This package provides seamless integration between Django REST framework and Datatables.

Install django-rest-framework-datatables, call your API with ?format=datatables and it will return a JSON structure that is fully compatible with what Datatables expects. It handles searching, filtering, ordering and most usecases you can imagine with Datatables.

The great benefit of django-rest-framework-datatables is that you don't have to create a different API, your API still work exactly the same unless you specify the datatables format on your request.

Full documentation is available on Read the Docs !

You can play with a demo of the example app on Python Anywhere.

Requirements

  • Python (3.5, 3.6, 3.7, 3.8, 3.9)
  • Django (2.0, 2.1, 2.2, 3.0, 3.1)
  • Django REST Framework (3.7, 3.8, 3.9, 3.10, 3.11, 3.12)

Note: Django 3.0 or superior is only supported with Django REST Framework 3.11 or superior and DRF-datatables version 0.5.1 or superior.

Quickstart

Installation

Just use pip:

Configuration

To enable Datatables support in your project, add 'rest_framework_datatables' to your INSTALLED_APPS, and modify your REST_FRAMEWORK settings like this:

And that's it !

Your API is now fully compatible with Datatables and will provide searching, filtering, ordering and pagination without any modification of your API code !

Always Serialize Specific Fields

Sometimes you may want to expose fields regardless of datatable's url parameters. You can do so by setting the datatables_always_serialize tuple like so:

An example of Datatable

Example project

To play with the example project, just clone the repository and run the dev server.

Testing

Install development requirements.

Run the tests.

You can also use the excellent tox testing tool to run the tests against all supported versions of Python and Django. Install tox globally, and then simply run:

If you want to check the coverage, use:

Documentation

The documentation is available online on Read the Docs.

To build the documentation, you’ll need to install sphinx.

To build the documentation:

About

Seamless integration between Django REST framework and Datatables.

http://django-rest-framework-datatables.readthedocs.io/en/latest/

License:MIT License


Languages

Language:JavaScript 71.1%Language:Python 26.1%Language:HTML 2.2%Language:CSS 0.7%