Skip to main content

Vista de procesamiento de tabla de datos del lado del servidor simple para Django-framework

Project description

Django Serverside Datatable

[Downloads]https://pypi.org/project/Serverside-tables-django-framework/

Este es un paquete simple que le permite usar Datatable del lado del servidor en su proyecto Django

Admite funciones de tabla de datos como paginación, búsqueda, etc.

Instalar

pip install django-serverside-datatable-post

Cómo utilizar

Create a django View that inherits from ServerSideDatatablePostView. Ejemplo (backend):

# views.py

from django_serverside_datatable_post.views import ServerSideDatatablePostView


class ItemListView(ServerSideDatatablePostView):
	queryset = models.Item.objects.all()
	columns = ['nombre', 'codigo', 'descripcion']


# urls.py
# agregue la siguiente línea a urlpatterns

path('data/', views.ItemListView.as_view(), name='url_test'), 

Ejemplo (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>Nombre</th>
					<th>Codigo</th>
					<th>Descripciion</th>
				</tr>
			</thead>
			<tbody></tbody>
		</table>

		<script src="https://code.jquery.com/jquery-3.6.3.js" integrity="sha256-nQLuAZGRRcILA+6dMBOvcRh5Pe310sBpanc6+QBmyVM=" crossorigin="anonymous"></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: "{% url 'url_test' %}",  // Agregar url
					sServerMethod: "POST", // se establece el metodo POST
					columns: [
						{name: "nombre", data: 0},
						{name: "codigo", data: 1},
						{name: "descripcion", data: 2},
					],
				});
			});
		</script>
	</body>
</html>

Para una mayor personalización de Datatable, puede consultar la documentación oficial de Datatable.

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

File details

Details for the file Serverside-tables-django-framework-0.0.3.tar.gz.

File metadata

File hashes

Hashes for Serverside-tables-django-framework-0.0.3.tar.gz
Algorithm Hash digest
SHA256 3efe1b8b7138bfbac1880257d673e35c399dbd14319473ac6677a6b6fde1adb3
MD5 7fc7e0a32b594d2c8abd21bce4ad60de
BLAKE2b-256 b724647564441e2e485cd515e432c56d5feafefe0099333b34d2314c3626ced0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page