Simple Server-side Datatable processing view for Django
Project description
Django Serverside Datatable
This is a simple package that let you use Server-side Datatable in your Django Project
Supports datatable features such as Pagination, Search, etc...
Install
pip install django-serverside-datatable
How to use
Create a django View that inherits from ServerSideDatatableView. Example (backend):
# views.py
from django_serverside_datatable.views import ServerSideDatatableView
class ItemListView(ServerSideDatatableView):
queryset = models.Item.objects.all()
columns = ['name', 'code', 'description']
# urls.py
# add the following line to urlpatterns
path('data/', views.ItemListView.as_view()),
Example (frontend):
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css">
</head>
<body>
<h1>Items</h1>
<hr>
<table id="items-table">
<thead>
<tr>
<th>Name</th>
<th>Code</th>
<th>Description</th>
</tr>
</thead>
<tbody></tbody>
</table>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
<script language="javascript">
$(document).ready(function () {
$('#items-table').dataTable({
serverSide: true,
sAjaxSource: "http://127.0.0.1:8000/data/", // new url
columns: [
{name: "name", data: 0},
{name: "code", data: 1},
{name: "description", data: 2},
],
});
});
</script>
</body>
</html>
For further customization of Datatable, you may refer the Datatable official documentation.
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
Built Distribution
File details
Details for the file django_serverside_datatable-2.1.0.tar.gz
.
File metadata
- Download URL: django_serverside_datatable-2.1.0.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 931fdf735ae591e739486d1baf404cc1c9cda1b95a17b68cc0990053c75f54ce |
|
MD5 | b28b96b3f8c0ce1d26054465738048f7 |
|
BLAKE2b-256 | 2553b29faa8352b6135a499ef5a87db80893a4cc55f9e01abaf4e2eb24cac7b8 |
File details
Details for the file django_serverside_datatable-2.1.0-py3-none-any.whl
.
File metadata
- Download URL: django_serverside_datatable-2.1.0-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 594cdf961291759fcec7a1111e582f095207098327fc62486b7f4d7c130fe5ae |
|
MD5 | a723e1089fd2123edc4c006ce8697cc4 |
|
BLAKE2b-256 | 0487154868772ef9872b600c857d9a4bd5e06d21b1aa62754c30ca082b73f736 |