温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

django怎么引用echarts

发布时间:2021-08-16 21:46:15 来源:亿速云 阅读:252 作者:chen 栏目:MySQL数据库

这篇文章主要讲解了“django怎么引用echarts”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“django怎么引用echarts”吧!

如果大家想用django架构来制作报表平台,可以使用django+echarts

具体如何引入echarts,如下:

1、新建项目 django_report

django-admin.py startproject django_report

2、新建app report01

python manage.py startapp report01

3、建立目录

cd /chunlei/django/django_report/

mkdir static

mkdir static/js

mkdir static/css

mkdir static/images

cd /chunlei/django/django_report/report01

mkdir templates

mkdir templates/report01_test

4、设置配置

cd /chunlei/django/django_report/django_report

vi settings.py

STATIC_URL = '/static/'

STATIC_ROOT = os.path.join(BASE_DIR, 'static').replace('\\', '/')

STATICFILES_DIRS = (

    ('css', os.path.join(STATIC_ROOT, 'css').replace('\\', '/')),

    ('js', os.path.join(STATIC_ROOT, 'js').replace('\\', '/')),

    ('images', os.path.join(STATIC_ROOT, 'images').replace('\\', '/')),

)

TIME_ZONE = 'Asia/Shanghai'

TEMPLATES = [

    {

        'BACKEND': 'django.template.backends.django.DjangoTemplates',

        'DIRS': ['/chunlei/chunlei/django/django_report/django_report/templates'],

        'APP_DIRS': True,

        'OPTIONS': {

            'context_processors': [

                'django.template.context_processors.debug',

                'django.template.context_processors.request',

                'django.contrib.auth.context_processors.auth',

                'django.contrib.messages.context_processors.messages',

            ],

        },

    },

]

INSTALLED_APPS = [

    'django.contrib.admin',

    'django.contrib.auth',

    'django.contrib.contenttypes',

    'django.contrib.sessions',

    'django.contrib.messages',

    'django.contrib.staticfiles',

   'report01',

]

ALLOWED_HOSTS = ['*']

5、上传echarts

下载

http://echarts.baidu.com/download.html

将下载的echarts.js 上传到 /chunlei/django/django_report/static/js/ 目录

6、url设置

cd /chunlei/django/django_report/django_report

vi urls.py

from django.conf.urls import url

from django.contrib import admin

from report01 import views as report01view

urlpatterns = [

    url(r'^report01/zhexian$',report01view.zhexian,name='zhexian'),

]

7、views.py设置

cd /chunlei/django/django_report/report01

vi views.py

from django.shortcuts import render

from django.shortcuts import render_to_response

from django.http import HttpResponse

def zhexian(request):

    return render_to_response('report01_test/zhexian.html')

8、测试网页配置

cd /chunlei/django/django_report/report01/templates/report01_test
vi zhexian.html

<head>

    <meta charset="utf-8">

    <title>ECharts</title>

    <!-- 引入 echarts.js -->

     <script type="text/javascript" src="/static/js/echarts.js"></script>

</head>

注:其他内容就不写出了,可以自由下载进行测试

9、开启

cd /chunlei/django/django_report

python manage.py  runserver IP:PORT

10、测试

http://IP:PORT/report01/zhexian

django怎么引用echarts

感谢各位的阅读,以上就是“django怎么引用echarts”的内容了,经过本文的学习后,相信大家对django怎么引用echarts这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是亿速云,小编将为大家推送更多相关知识点的文章,欢迎关注!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI