{"id":19940715,"url":"https://github.com/izimobil/django-rest-framework-datatables","last_synced_at":"2025-05-15T16:06:21.412Z","repository":{"id":40596870,"uuid":"128900053","full_name":"izimobil/django-rest-framework-datatables","owner":"izimobil","description":"Seamless integration between Django REST framework and Datatables.","archived":false,"fork":false,"pushed_at":"2024-07-29T07:02:15.000Z","size":355,"stargazers_count":399,"open_issues_count":18,"forks_count":90,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-05-13T15:29:04.796Z","etag":null,"topics":["api","datagrid","datatable-serverside","datatables","django","django-rest-framework","drf"],"latest_commit_sha":null,"homepage":"http://django-rest-framework-datatables.readthedocs.io/en/latest/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/izimobil.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["izimobil"]}},"created_at":"2018-04-10T08:30:20.000Z","updated_at":"2025-04-18T19:27:35.000Z","dependencies_parsed_at":"2024-02-18T23:31:56.601Z","dependency_job_id":"dd9dfc32-1750-401f-a6d8-5e7bd1ffe7bf","html_url":"https://github.com/izimobil/django-rest-framework-datatables","commit_stats":{"total_commits":146,"total_committers":28,"mean_commits":5.214285714285714,"dds":0.5068493150684932,"last_synced_commit":"4f9d81588addcda5f9beac11d55b15deed99ae47"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/izimobil%2Fdjango-rest-framework-datatables","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/izimobil%2Fdjango-rest-framework-datatables/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/izimobil%2Fdjango-rest-framework-datatables/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/izimobil%2Fdjango-rest-framework-datatables/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/izimobil","download_url":"https://codeload.github.com/izimobil/django-rest-framework-datatables/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254374470,"owners_count":22060611,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","datagrid","datatable-serverside","datatables","django","django-rest-framework","drf"],"created_at":"2024-11-13T00:06:33.896Z","updated_at":"2025-05-15T16:06:21.384Z","avatar_url":"https://github.com/izimobil.png","language":"Python","funding_links":["https://github.com/sponsors/izimobil"],"categories":[],"sub_categories":[],"readme":"django-rest-framework-datatables\n================================\n\n|build-status-image| |codecov-image| |documentation-status-image| |pypi-version| |py-versions|\n\nOverview\n--------\n\nThis package provides seamless integration between `Django REST framework \u003chttps://www.django-rest-framework.org\u003e`_ and `Datatables \u003chttps://datatables.net\u003e`_.\n\nInstall 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.\nIt handles searching, filtering, ordering and most usecases you can imagine with Datatables.\n\nThe 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.\n\nFull documentation is available on `Read the Docs \u003chttp://django-rest-framework-datatables.readthedocs.io/en/latest/\u003e`_ !\n\nYou can play with a demo of the example app on `Python Anywhere \u003chttps://izimobil.pythonanywhere.com\u003e`_.\n\nRequirements\n------------\n\n- Python (3.8, 3.9, 3.10, 3.11, 3.12)\n- Django (3.2, 4.1, 4.2)\n- Django REST Framework (3.14)\n\nWe highly recommend and only officially support the latest patch release of each Python, Django and Django Rest Framework series.\n\nQuickstart\n----------\n\nInstallation\n~~~~~~~~~~~~\n\nJust use ``pip``:\n\n.. code:: bash\n\n    $ pip install djangorestframework-datatables\n\nConfiguration\n~~~~~~~~~~~~~\n\nTo enable Datatables support in your project, add ``'rest_framework_datatables'`` to your ``INSTALLED_APPS``, and modify your ``REST_FRAMEWORK`` settings like this:\n\n.. code:: python\n\n    REST_FRAMEWORK = {\n        'DEFAULT_RENDERER_CLASSES': (\n            'rest_framework.renderers.JSONRenderer',\n            'rest_framework.renderers.BrowsableAPIRenderer',\n            'rest_framework_datatables.renderers.DatatablesRenderer',\n        ),\n        'DEFAULT_FILTER_BACKENDS': (\n            'rest_framework_datatables.filters.DatatablesFilterBackend',\n        ),\n        'DEFAULT_PAGINATION_CLASS': 'rest_framework_datatables.pagination.DatatablesPageNumberPagination',\n        'PAGE_SIZE': 50,\n    }\n\nAnd that's it !\n~~~~~~~~~~~~~~~\n\nYour API is now fully compatible with Datatables and will provide searching, filtering, ordering and pagination without any modification of your API code !\n\nAlways Serialize Specific Fields\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\nSometimes 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:\n\n.. code:: python\n\n    class ArtistSerializer(serializers.ModelSerializer):\n        id = serializers.IntegerField(read_only=True)\n    \n        class Meta:\n            model = Artist\n            fields = (\n                'id', 'name',\n            )\n            datatables_always_serialize = ('id',)\n\nAn example of Datatable\n~~~~~~~~~~~~~~~~~~~~~~~\n\n.. code:: html\n\n    \u003c!doctype html\u003e\n    \u003chtml lang=\"en\"\u003e\n    \u003chead\u003e\n      \u003cmeta charset=\"utf-8\"\u003e\n      \u003ctitle\u003eRolling Stone Top 500 albums of all time\u003c/title\u003e\n      \u003clink rel=\"stylesheet\" href=\"//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0/css/bootstrap.css\"\u003e\n      \u003clink rel=\"stylesheet\" href=\"//cdn.datatables.net/1.10.16/css/dataTables.bootstrap4.min.css\"\u003e\n    \u003c/head\u003e\n    \n    \u003cbody\u003e\n      \u003cdiv class=\"container\"\u003e\n        \u003cdiv class=\"row\"\u003e\n          \u003cdiv class=\"col-sm-12\"\u003e\n            \u003ctable id=\"albums\" class=\"table table-striped table-bordered\" style=\"width:100%\"\u003e\n              \u003cthead\u003e\n                \u003ctr\u003e\n                  \u003cth\u003eRank\u003c/th\u003e\n                  \u003cth\u003eArtist\u003c/th\u003e\n                  \u003cth\u003eAlbum name\u003c/th\u003e\n                  \u003cth\u003eYear\u003c/th\u003e\n                  \u003cth\u003eGenres\u003c/th\u003e\n                \u003c/tr\u003e\n              \u003c/thead\u003e\n            \u003c/table\u003e\n          \u003c/div\u003e\n        \u003c/div\u003e\n      \u003c/div\u003e\n      \u003cscript src=\"//code.jquery.com/jquery-1.12.4.js\"\u003e\u003c/script\u003e\n      \u003cscript src=\"//cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js\"\u003e\u003c/script\u003e\n      \u003cscript src=\"//cdn.datatables.net/1.10.16/js/dataTables.bootstrap4.min.js\"\u003e\u003c/script\u003e\n      \u003cscript\u003e\n          $(document).ready(function() {\n              var table = $('#albums').DataTable({\n                  \"serverSide\": true,\n                  \"ajax\": \"/api/albums/?format=datatables\",\n                  \"columns\": [\n                      {\"data\": \"rank\", \"searchable\": false},\n                      {\"data\": \"artist_name\", \"name\": \"artist.name\"},\n                      {\"data\": \"name\"},\n                      {\"data\": \"year\"},\n                      {\"data\": \"genres\", \"name\": \"genres.name\", \"sortable\": false},\n                  ]\n              });\n          });\n      \u003c/script\u003e\n    \u003c/body\u003e\n    \u003c/html\u003e\n\nExample project\n---------------\n\nTo play with the example project, just clone the repository and run the dev server.\n\n.. code:: bash\n\n    $ git clone https://github.com/izimobil/django-rest-framework-datatables.git\n    $ cd django-rest-framework-datatables\n    $ pip install -r requirements-dev.txt\n    $ python example/manage.py runserver\n    $ firefox http://127.0.0.1:8000\n\nTesting\n-------\n\nInstall development requirements.\n\n.. code:: bash\n\n    $ pip install -r requirements-dev.txt\n\nRun the tests.\n\n.. code:: bash\n\n    $ python example/manage.py test\n\nYou can also use the excellent `tox`_ testing tool to run the tests\nagainst all supported versions of Python and Django. Install tox\nglobally, and then simply run:\n\n.. code:: bash\n\n    $ tox\n\nIf you want to check the coverage, use:\n\n.. code:: bash\n\n    $ coverage run ./example/manage.py test\n    $ coverage report -m\n\nDocumentation\n-------------\n\nThe documentation is available online on `Read the Docs \u003chttp://django-rest-framework-datatables.readthedocs.io/en/latest/\u003e`_.\n\nTo build the documentation, you’ll need to install ``sphinx``.\n\n.. code:: bash\n\n    $ pip install -r requirements-docs.txt\n\nTo build the documentation:\n\n.. code:: bash\n\n    $ cd docs\n    $ make clean \u0026\u0026 make html\n\n\n.. _tox: http://tox.readthedocs.org/en/latest/\n\n.. |build-status-image| image:: https://api.travis-ci.com/izimobil/django-rest-framework-datatables.svg?branch=master\n   :target: https://app.travis-ci.com/github/izimobil/django-rest-framework-datatables\n   :alt: Travis build\n\n.. |codecov-image| image:: https://codecov.io/gh/izimobil/django-rest-framework-datatables/branch/master/graph/badge.svg\n  :target: https://codecov.io/gh/izimobil/django-rest-framework-datatables\n\n.. |pypi-version| image:: https://img.shields.io/pypi/v/djangorestframework-datatables.svg\n   :target: https://pypi.python.org/pypi/djangorestframework-datatables\n   :alt: Pypi version\n\n.. |documentation-status-image| image:: https://readthedocs.org/projects/django-rest-framework-datatables/badge/?version=latest\n   :target: http://django-rest-framework-datatables.readthedocs.io/en/latest/?badge=latest\n   :alt: Documentation Status\n\n.. |py-versions| image:: https://img.shields.io/pypi/pyversions/djangorestframework-datatables.svg\n   :target: https://img.shields.io/pypi/pyversions/djangorestframework-datatables.svg\n   :alt: Python versions\n\n.. |dj-versions| image:: https://img.shields.io/pypi/djversions/djangorestframework-datatables.svg\n   :target: https://img.shields.io/pypi/djversions/djangorestframework-datatables.svg\n   :alt: Django versions\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fizimobil%2Fdjango-rest-framework-datatables","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fizimobil%2Fdjango-rest-framework-datatables","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fizimobil%2Fdjango-rest-framework-datatables/lists"}