Django uses pyecharts (5) django joins echarts_incremental update_fixed length

5. Django front-end and back-end separation_timed incremental update chart fixed-length data 1. Install djangorestframework linux pip3 install djangorestframework windows pip install djangorestframework 2. Create a new Django Project$ django-admin startproject pyecharts_django_demo_5 Create an application $ python manage.py startapp demo Register the application in pyecharts_django_demo_5/settings.py # pyecharts_django_demo_5/settings.py INSTALLED_APPS = [ ‘django.contrib.admin’, ‘django.contrib.auth’, ‘django.contrib.contenttypes’, > ‘django.contrib.sessions’, ‘django.contrib.messages’, ‘django.contrib.staticfiles’, ‘demo’, # <— app name ‘rest_framework ‘, ] Add ‘demo.urls’ in pyecharts_django_demo_5/urls.py from django.contrib import admin from django.urls import path from django.conf.urls import url, include urlpatterns = [ path(‘admin/’, admin.site.urls),url(r’^demo/’, include(‘demo.urls’)) ] 3. Write HTML code for drawing Create a templates folder under the root directory folder first, create a new index.html, and the core of timing refresh lies in the setInterval method of html. File directory situation __pycache__ db.sqlite3 demo manage.py pyecharts_django_demo_5 templates index.html 3. Write Django and pyecharts code to render the chart Save the following code to demo/views.py Backend code Changes need to be made accordingly Edit the demo/urls.py file (if not, create a new one) from django.conf.urls import url from . import views urlpatterns = [ url(r’^line/$’, views.ChartView.as_view(), name=’demo’), url(r’^lineUpdate/$’, views.ChartUpdateView .as_view(), name=’demo’), url(r’^index/$’, views.IndexView.as_view(), name=’demo’), ] demo. view. from django.shortcuts import render # Create your views here. import json…

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索