All Projects → vertliba → django-rest-framework-datatables-editor

vertliba / django-rest-framework-datatables-editor

Licence: MIT license
Seamless integration between Django REST framework, Datatables and Datatables Editor.

Programming Languages

javascript
184084 projects - #8 most used programming language
CSS
56736 projects
python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to django-rest-framework-datatables-editor

Django Rest Framework Datatables
Seamless integration between Django REST framework and Datatables.
Stars: ✭ 241 (+864%)
Mutual labels:  datatables, django-rest-framework
django-ninja-extra
Django Ninja Extra - Class-Based Utility and more for Django Ninja(Fast Django REST framework)
Stars: ✭ 53 (+112%)
Mutual labels:  django-rest-framework, drf
drf-angular-docker-tutorial
Dockerized Django Back-end API using DRF with Angular Front-end Tutorial
Stars: ✭ 53 (+112%)
Mutual labels:  django-rest-framework, drf
Drf Datatable Example Server Side
DataTables Example (server-side) - Python Django REST framework
Stars: ✭ 84 (+236%)
Mutual labels:  datatables, django-rest-framework
django-rest-multitokenauth
An extension to Django-Rest-Frameworks Token Authentication, enabling a user to have multiple authorization tokens
Stars: ✭ 13 (-48%)
Mutual labels:  django-rest-framework, drf
django-rest-framework-recaptcha
reCAPTCHA field for Django REST framework serializers
Stars: ✭ 24 (-4%)
Mutual labels:  django-rest-framework, drf
drf-registration
Simple user registration package based on Django Rest Framework. DRF Registration - The easy way to generate registration RESTful APIs
Stars: ✭ 32 (+28%)
Mutual labels:  django-rest-framework, drf
django-learning-pathway
(Currently in development) Learning pathways for learning Django.
Stars: ✭ 35 (+40%)
Mutual labels:  django-rest-framework
Auto-DL
Auto-DL helps you make Deep Learning models without writing a single line of code and giving as little input as possible.
Stars: ✭ 165 (+560%)
Mutual labels:  django-rest-framework
ant-table-extensions
Export, Search extensions to Ant Design's Table component.
Stars: ✭ 43 (+72%)
Mutual labels:  datatables
laravel-datatables-editor
Laravel DataTables Editor Integration.
Stars: ✭ 105 (+320%)
Mutual labels:  datatables
Malicious-Urlv5
A multi-layered and multi-tiered Machine Learning security solution, it supports always on detection system, Django REST framework used, equipped with a web-browser extension that uses a REST API call.
Stars: ✭ 35 (+40%)
Mutual labels:  django-rest-framework
logi-filter-builder
advanced SQL filter builder. Demo:
Stars: ✭ 23 (-8%)
Mutual labels:  datatables
drf-action-serializer
A serializer for the Django Rest Framework that supports per-action serialization of fields.
Stars: ✭ 48 (+92%)
Mutual labels:  django-rest-framework
vue-datatables
No description or website provided.
Stars: ✭ 22 (-12%)
Mutual labels:  datatables
filtermapbackend
FilterMapBackend for django-rest-framework
Stars: ✭ 16 (-36%)
Mutual labels:  django-rest-framework
drf ujson2
JSON parser and renderer using ujson for Django Rest Framework
Stars: ✭ 29 (+16%)
Mutual labels:  django-rest-framework
machado
This repository provides users with a framework to store, search and visualize biological data.
Stars: ✭ 18 (-28%)
Mutual labels:  django-rest-framework
datatable-examples
Using DataTables plug-in for jQuery
Stars: ✭ 29 (+16%)
Mutual labels:  datatables
new-ara-api
KAIST Community Ara Renewal Project - KAIST official BBS
Stars: ✭ 15 (-40%)
Mutual labels:  drf

django-rest-framework-datatables-editor

Build codecov-image Documentation Status Pypi version Python versions Django versions

Overview

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

  • It handles searching, filtering, ordering and most usecases you can imagine with Datatables.
  • You don't have to create a different API, your API still work exactly the same .

How to use

Install

$ pip install djangorestframework-datatables-editor

If you need the functionality of the editor, you also need to download the data editor from here, the JS+CSS version, and put the downloaded files in static folder.

Configuration

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

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

For using Datatables editor you should use DatatablesEditorModelViewSet instead ModelViewSet or add EditorModelMixin to your views.

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 ! For using Datatables editor you should use DatatablesEditorModelViewSet instead ModelViewSet or add EditorModelMixin to your views.

Configuring Datatables and Datatables editor

  • The URL for connecting datatables is the URL of your view with ?format=datatables
  • The URL connecting datatables editor is the URL of your view with editor/
  • Full documentation is available on Read the Docs !
  • Also you'll need download Datatables editor.

Example of HTML code:

<!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.1.3/css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.19/css/dataTables.bootstrap4.min.css">
    <link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.5.6/css/buttons.bootstrap4.min.css">
    <link rel="stylesheet" href="https://cdn.datatables.net/select/1.3.0/css/select.bootstrap4.min.css">
    <link rel="stylesheet" href="/static/css/editor.bootstrap4.min.css">
</head>
<body>
    <div class="container" style="font-size: .9em;">
        <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-3.3.1.js"></script>
    <script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/js/bootstrap.min.js"></script>
    <script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
    <script src="https://cdn.datatables.net/1.10.19/js/dataTables.bootstrap4.min.js"></script>
    <script src="https://cdn.datatables.net/buttons/1.5.6/js/dataTables.buttons.min.js"></script>
    <script src="https://cdn.datatables.net/buttons/1.5.6/js/buttons.bootstrap4.min.js"></script>
    <script src="https://cdn.datatables.net/select/1.3.0/js/dataTables.select.min.js"></script>
    <script src="/static/js/dataTables.editor.js"></script>
    <script src="/static/js/editor.bootstrap4.min.js"></script>
    <script>
        $(document).ready(function () {
            editor = new $.fn.dataTable.Editor({
                ajax: "/api/albums/editor/?format=datatables",
                table: "#albums",
                fields: [{
                    label: "rank",
                    name: "rank",
                }, {
                    label: "artist:",
                    name: "artist.id",
                    type: "select"
                }, {
                    label: "name:",
                    name: "name",
                }, {
                    label: "year:",
                    name: "year",
                }]
            });
            var table = $('#albums').DataTable({
                "serverSide": true,
                dom: "Bfrtip",
                "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},
                ],
                select: true,
                buttons: [
                    {extend: "create", editor: editor},
                    {extend: "edit", editor: editor},
                    {extend: "remove", editor: editor}
                ]
            });
            table.buttons().container()
                .appendTo($('.col-md-6:eq(0)', table.table().container()));
        });
    </script>
</body>
</html>

Thanks

The project is based on the project django-rest-framework-datatables by David Jean Louis

Requirements

  • Python (2.7, 3.4, 3.5, 3.6, 3.7, 3.8)
  • Django (1.9, 1.11, 2.0, 2.1, 2.2, 3.0)
  • Django REST Framework (3.9, 3.10, 3.11)

Example project

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

$ git clone https://github.com/VVyacheslav/DRF-datatables-editor.git
$ cd DRF-datatables-editor
Activate virtualenv.
$ pip install -r requirements-dev.txt
$ python example/manage.py runserver
$ firefox http://127.0.0.1:8000

Testing

Install development requirements.

$ pip install -r requirements-dev.txt

Run the tests.

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

$ tox

If you want to check the coverage, use:

$ coverage run ./example/manage.py test
$ coverage report -m
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].