All Projects → twtrubiks → Drf Datatable Example Server Side

twtrubiks / Drf Datatable Example Server Side

Licence: mit
DataTables Example (server-side) - Python Django REST framework

Projects that are alternatives of or similar to Drf Datatable Example Server Side

Django Rest Framework Datatables
Seamless integration between Django REST framework and Datatables.
Stars: ✭ 241 (+186.9%)
Mutual labels:  django, django-rest-framework, datatables
Django Vue Template
Django Rest + Vue JS Template
Stars: ✭ 1,155 (+1275%)
Mutual labels:  django, django-rest-framework
Thinkdiff
My open source project links, programming and software development related code and tutorials are in this repo. Content types: Python, JavaScript, Dart | Django, React, Flutter, React-Native etc.
Stars: ✭ 65 (-22.62%)
Mutual labels:  django, django-rest-framework
Ara
ARA Records Ansible and makes it easier to understand and troubleshoot.
Stars: ✭ 1,176 (+1300%)
Mutual labels:  django, django-rest-framework
Django React
This a simple Django and React demo application
Stars: ✭ 63 (-25%)
Mutual labels:  django, django-rest-framework
Django Crm
A Simple Django CRM (Customer Relationship Management) RESTful API Project
Stars: ✭ 63 (-25%)
Mutual labels:  django, django-rest-framework
Django Rest React Pycon
🐍 Demo repo for Pycon X talk "Decoupling Django with Django REST (and a sprinkle of React)"
Stars: ✭ 72 (-14.29%)
Mutual labels:  django, django-rest-framework
Drf Recaptcha
Django REST framework reCAPTCHA
Stars: ✭ 47 (-44.05%)
Mutual labels:  django, django-rest-framework
Generator Django Rest
Yeoman generator for a Django REST/GraphQL API, an optional React SPA & lots more!
Stars: ✭ 77 (-8.33%)
Mutual labels:  django, django-rest-framework
Django Rest Framework Msgpack
MessagePack support for Django REST framework
Stars: ✭ 78 (-7.14%)
Mutual labels:  django, django-rest-framework
Codingwithmitchblog Rest Api
A continuation of the CodingWithMitchBlog course. Adding a REST API using Django REST-framework
Stars: ✭ 78 (-7.14%)
Mutual labels:  django, django-rest-framework
Drf Nested Routers
Nested Routers for Django Rest Framework
Stars: ✭ 1,098 (+1207.14%)
Mutual labels:  django, django-rest-framework
Django Rest Framework Tricks
Collection of various tricks for Django REST framework.
Stars: ✭ 52 (-38.1%)
Mutual labels:  django, django-rest-framework
Best Of Web Python
🏆 A ranked list of awesome python libraries for web development. Updated weekly.
Stars: ✭ 1,118 (+1230.95%)
Mutual labels:  django, django-rest-framework
Django Channels React Multiplayer
turn based strategy game using django channels, redux, and react hooks
Stars: ✭ 52 (-38.1%)
Mutual labels:  django, django-rest-framework
Indrz
Indoor mapping, routing system for orientation and wayfinding or facility management
Stars: ✭ 69 (-17.86%)
Mutual labels:  django, django-rest-framework
Drf Autodocs
Ultimately automated DRF documentation rendering(UNMAINTAINED)
Stars: ✭ 82 (-2.38%)
Mutual labels:  django, django-rest-framework
Ponee
A lightweight Django template ready for Heroku
Stars: ✭ 41 (-51.19%)
Mutual labels:  django, django-rest-framework
Django Rest Pandas
📊📈 Serves up Pandas dataframes via the Django REST Framework for use in client-side (i.e. d3.js) visualizations and offline analysis (e.g. Excel)
Stars: ✭ 1,030 (+1126.19%)
Mutual labels:  django, django-rest-framework
Awesome Django
Repository mirror of GitLab: https://gitlab.com/rosarior/awesome-django This repository is not monitored for issues, use original at GitLab.
Stars: ✭ 8,527 (+10051.19%)
Mutual labels:  django, django-rest-framework

DRF-dataTable-Example-server-side

此版本為 django<2.0,以及搭配 SQLite 的範例,

如果使用 Django>2.0,請參考 django_2_and_mysql_5.7 branch

DataTables Example (server-side) - Python Django REST framework

DataTables (server-side) 搭配 Django REST framework 簡單範例 📝

特色

安裝套件

請在你的命令提示字元 (cmd ) 底下輸入

安裝 Django

這邊請注意,django<2.0 ( django 請安裝小於 2.0 的版本)

pip install Django==1.11.20

安裝 Django-REST-framework

pip install djangorestframework

安裝 django-model-utils

pip install django-model-utils

或是使用 cmd (命令提示字元)

pip install -r requirements.txt

說明

  • LOG 資訊非常重要,可以參考官網 django logging , 或是看範例裡面的 settings.py 裡面的 LOGGING。

  • 建議透過 django-db-backends 來觀看目前的 orm 到底執行了什麼 SQL 指令,可以到範例裡面的 settings.py 找 django.db.backends。

執行方法

使用命令提示字元 ( cmd ) 輸入下方指令

python manage.py runserver

然後瀏覽

http://127.0.0.1:8000/index/

執行畫面

首頁

[Get] api/music/{額外 DataTables 參數}

alt tag

新增

[POST] api/music/

alt tag

編輯

[PUT] api/music/{id}/

alt tag

刪除

[DELETE] api/music/{id}/

alt tag

搜尋 排序

[Get] api/music/{ 額外 DataTables 參數 }

alt tag

後記

  • 從影片中的 demo 可以很明顯的看出當資料量很大(5 萬筆)的時候,如果沒有用 server-side 的方式,而是一次全部載入,使用者體驗非常差。

  • 本範例前後端並沒有分離,而是寫在一起,比較好的方式,應該是前後端分離。

  • api document 可參考 api_document.html ,直接用瀏覽器開啟即可。 ( 文件教學可參考 aglio_tutorial )

更換 MySQL 資料庫

因為有些人反映換成 MySQL 之後無法 work,所以我測試了一下,

步驟一,先要多安裝兩個套件,

安裝 PyMySQL

pip install PyMySQL

安裝 mysqlclient

pip install mysqlclient

( 這個有可能安裝不起來,我自己最後是去找 mysqlclient-1.4.2-cp36-cp36m-win32.whl 安裝成功 )

settings.py 要改成

......

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'demo',
        'USER': 'root',
        'PASSWORD': 'password123',
        'HOST': '127.0.0.1',
        'PORT': '3306',
    }
}

......

也可參考之前的文章 Django 如何連結 MySQL

這邊要特別注意,MySQL 我使用 5.7,如果使用 MySQL 8.0,會遇到 django.db.utils.OperationalError: (2059, )

的問題,原因是 MySQL 8.0 的密碼加密方式改成了 caching_sha2_password,要再自行修改,簡單一點就是使用

MySQL 5.7。

執行環境

  • Python 3.6.6

Reference

Donation

文章都是我自己研究內化後原創,如果有幫助到您,也想鼓勵我的話,歡迎請我喝一杯咖啡😆

alt tag

贊助者付款

License

MIT license

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].