All Projects β†’ izimobil β†’ Django Rest Framework Datatables

izimobil / Django Rest Framework Datatables

Licence: mit
Seamless integration between Django REST framework and Datatables.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Django Rest Framework Datatables

Django rest example
Django/DRF rest application example.
Stars: ✭ 17 (-92.95%)
Mutual labels:  api, django, django-rest-framework
Best Of Web Python
πŸ† A ranked list of awesome python libraries for web development. Updated weekly.
Stars: ✭ 1,118 (+363.9%)
Mutual labels:  api, django, django-rest-framework
Awesome Django Rest Framework
πŸ’»πŸ˜Tools, processes and resources you need to create an awesome API with Django REST Framework
Stars: ✭ 689 (+185.89%)
Mutual labels:  api, django, django-rest-framework
Django Api Domains
A pragmatic styleguide for Django API Projects
Stars: ✭ 365 (+51.45%)
Mutual labels:  api, django, django-rest-framework
Tutorialdb
A search πŸ”Ž engine for programming/dev tutorials, See it in action πŸ‘‰
Stars: ✭ 93 (-61.41%)
Mutual labels:  api, django, django-rest-framework
Ara
ARA Records Ansible and makes it easier to understand and troubleshoot.
Stars: ✭ 1,176 (+387.97%)
Mutual labels:  api, django, django-rest-framework
Postgraduation
University management platform dedicated for post-graduation in computer science field using django rest framework.
Stars: ✭ 35 (-85.48%)
Mutual labels:  api, django, django-rest-framework
Rest Api
Learn how to build your own REST API with Python, Django, and the Django Rest Framework.
Stars: ✭ 232 (-3.73%)
Mutual labels:  api, django, django-rest-framework
Drf Datatable Example Server Side
DataTables Example (server-side) - Python Django REST framework
Stars: ✭ 84 (-65.15%)
Mutual labels:  django, django-rest-framework, datatables
Drf Autodocs
Ultimately automated DRF documentation rendering(UNMAINTAINED)
Stars: ✭ 82 (-65.98%)
Mutual labels:  api, django, django-rest-framework
Django Jinja Knockout
Django datatables and widgets, both AJAX and traditional. Display-only ModelForms. ModelForms / inline formsets with AJAX submit and validation. Works with Django templates.
Stars: ✭ 116 (-51.87%)
Mutual labels:  django, datagrid, datatables
Usaspending Api
Server application to serve U.S. federal spending data via a RESTful API
Stars: ✭ 166 (-31.12%)
Mutual labels:  api, django, django-rest-framework
Django Rest Framework Serializer Extensions
Extensions to help DRY up Django Rest Framework serializers
Stars: ✭ 180 (-25.31%)
Mutual labels:  django, django-rest-framework
Crud App Vuejs Django
This is simple crud app and searchFilter made using vuejs and django. Used to explain the tutorial present on https://medium.com/@shubhambansal_89125/crud-app-using-vue-js-and-django-516edf4e4217 https://medium.com/@shubhambansal_89125/searchfilter-using-django-and-vue-js-215af82e12cd
Stars: ✭ 174 (-27.8%)
Mutual labels:  django, django-rest-framework
Django Enumfield
Custom Django field for using enumerations of named constants
Stars: ✭ 184 (-23.65%)
Mutual labels:  django, django-rest-framework
Djangorestframework Stubs
PEP-484 stubs for django-rest-framework
Stars: ✭ 191 (-20.75%)
Mutual labels:  django, django-rest-framework
Graphene Django Subscriptions
This package adds support to Subscription's requests and its integration with websockets using Channels package.
Stars: ✭ 173 (-28.22%)
Mutual labels:  api, django
Drf Yasg
Automated generation of real Swagger/OpenAPI 2.0 schemas from Django REST Framework code.
Stars: ✭ 2,523 (+946.89%)
Mutual labels:  django, django-rest-framework
Tacticalrmm
A remote monitoring & management tool, built with Django, Vue and Go.
Stars: ✭ 231 (-4.15%)
Mutual labels:  django, django-rest-framework
Django Rest Auth
This app makes it extremely easy to build Django powered SPA's (Single Page App) or Mobile apps exposing all registration and authentication related functionality as CBV's (Class Base View) and REST (JSON)
Stars: ✭ 2,289 (+849.79%)
Mutual labels:  django, django-rest-framework

django-rest-framework-datatables

|build-status-image| |codecov-image| |documentation-status-image| |pypi-version| |py-versions|

Overview

This package provides seamless integration between Django REST framework <https://www.django-rest-framework.org>_ and Datatables <https://datatables.net>_.

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 <http://django-rest-framework-datatables.readthedocs.io/en/latest/>_ !

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``:

.. code:: bash

    $ pip install djangorestframework-datatables

Configuration

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

.. code:: python

REST_FRAMEWORK = {
    'DEFAULT_RENDERER_CLASSES': (
        'rest_framework.renderers.JSONRenderer',
        'rest_framework.renderers.BrowsableAPIRenderer',
        'rest_framework_datatables.renderers.DatatablesRenderer',
    ),
    'DEFAULT_FILTER_BACKENDS': (
        'rest_framework_datatables.filters.DatatablesFilterBackend',
    ),
    'DEFAULT_PAGINATION_CLASS': 'rest_framework_datatables.pagination.DatatablesPageNumberPagination',
    'PAGE_SIZE': 50,
}

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:

.. code:: python

class ArtistSerializer(serializers.ModelSerializer):
    id = serializers.IntegerField(read_only=True)

    class Meta:
        model = Artist
        fields = (
            'id', 'name',
        )
        datatables_always_serialize = ('id',)

An example of Datatable


.. code:: html

    <!doctype html>
    <html lang="en">
    <head>
      <meta charset="utf-8">
      <title>Rolling Stone Top 500 albums of all time</title>
      <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0/css/bootstrap.css">
      <link rel="stylesheet" href="//cdn.datatables.net/1.10.16/css/dataTables.bootstrap4.min.css">
    </head>
    
    <body>
      <div class="container">
        <div class="row">
          <div class="col-sm-12">
            <table id="albums" class="table table-striped table-bordered" style="width:100%">
              <thead>
                <tr>
                  <th>Rank</th>
                  <th>Artist</th>
                  <th>Album name</th>
                  <th>Year</th>
                  <th>Genres</th>
                </tr>
              </thead>
            </table>
          </div>
        </div>
      </div>
      <script src="//code.jquery.com/jquery-1.12.4.js"></script>
      <script src="//cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
      <script src="//cdn.datatables.net/1.10.16/js/dataTables.bootstrap4.min.js"></script>
      <script>
          $(document).ready(function() {
              var table = $('#albums').DataTable({
                  "serverSide": true,
                  "ajax": "/api/albums/?format=datatables",
                  "columns": [
                      {"data": "rank", "searchable": false},
                      {"data": "artist_name", "name": "artist.name"},
                      {"data": "name"},
                      {"data": "year"},
                      {"data": "genres", "name": "genres.name", "sortable": false},
                  ]
              });
          });
      </script>
    </body>
    </html>

Example project
---------------

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

.. code:: bash

    $ git clone https://github.com/izimobil/django-rest-framework-datatables.git
    $ cd django-rest-framework-datatables
    $ pip install -r requirements-dev.txt
    $ python example/manage.py runserver
    $ firefox http://127.0.0.1:8000

Testing
-------

Install development requirements.

.. code:: bash

    $ pip install -r requirements-dev.txt

Run the tests.

.. code:: bash

    $ python example/manage.py test

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:

.. code:: bash

    $ tox

If you want to check the coverage, use:

.. code:: bash

    $ coverage run ./example/manage.py test
    $ coverage report -m

Documentation
-------------

The documentation is available online on `Read the Docs <http://django-rest-framework-datatables.readthedocs.io/en/latest/>`_.

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

.. code:: bash

    $ pip install -r requirements-docs.txt

To build the documentation:

.. code:: bash

    $ cd docs
    $ make clean && make build


.. _tox: http://tox.readthedocs.org/en/latest/

.. |build-status-image| image:: https://secure.travis-ci.org/izimobil/django-rest-framework-datatables.svg?branch=master
   :target: http://travis-ci.org/izimobil/django-rest-framework-datatables?branch=master
   :alt: Travis build

.. |codecov-image| image:: https://codecov.io/gh/izimobil/django-rest-framework-datatables/branch/master/graph/badge.svg
  :target: https://codecov.io/gh/izimobil/django-rest-framework-datatables

.. |pypi-version| image:: https://img.shields.io/pypi/v/djangorestframework-datatables.svg
   :target: https://pypi.python.org/pypi/djangorestframework-datatables
   :alt: Pypi version

.. |documentation-status-image| image:: https://readthedocs.org/projects/django-rest-framework-datatables/badge/?version=latest
   :target: http://django-rest-framework-datatables.readthedocs.io/en/latest/?badge=latest
   :alt: Documentation Status

.. |py-versions| image:: https://img.shields.io/pypi/pyversions/djangorestframework-datatables.svg
   :target: https://img.shields.io/pypi/pyversions/djangorestframework-datatables.svg
   :alt: Python versions

.. |dj-versions| image:: https://img.shields.io/pypi/djversions/djangorestframework-datatables.svg
   :target: https://img.shields.io/pypi/djversions/djangorestframework-datatables.svg
   :alt: Django versions
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].