1.配置mathjax

需要的插件分别是  widget, dialog, mathjax

①添加插件②        'mathJaxLib': '//cdn.mathjax.org/mathjax/2.6-latest/MathJax.js?config=TeX-AMS_HTML',③添加到工具栏按钮,Mathjax(区分大小写)

setting.py

CKEDITOR_CONFIGS = {
    'default': {
       
        'toolbar': 'Custom',
        # 工具栏按钮
        'toolbar_Custom': [
            
            ['Mathjax'],
        ],

        'mathJaxLib': '//cdn.mathjax.org/mathjax/2.6-latest/MathJax.js?config=TeX-AMS_HTML',

        # 加入代码块插件
        'extraPlugins': ','.join([
                                  'widget',
                                  'dialog',
                                  'dialogui',
                                   'mathjax',

                                  ]),

    },
}

我们到页面上刷新,就能看到效果了

2.修改html显示

如果我们需要在我们的页面上访问到,需要对html页面进行修改,分别插入下面两个js,

detail.html

<script type="text/x-mathjax-config">
    MathJax.Hub.Config({
      tex2jax: {inlineMath: [["$","$"],["\\(","\\)"]]}
    });
</script>
 
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>

最后下html网页显示了

 

3.prism

//路径:C:\Users\yys53\OneDrive\python\blog\static\prism\prism.css
<link rel="stylesheet" href="{% static 'prism/prism.css' %}">

//乌班图20.04所在路径~/.local/lib/python3.8/site-packages/ckeditor/static/ckeditor/ckeditor/plugins
//路径:C:\Users\yys53\OneDrive\python\install\Lib\site-packages\ckeditor\static\ckeditor\ckeditor\plugins\prism\
//刚装django-ckeditor时,没有prism文件的,如果CKeditor不显示,是因为settings.py添加这个插件,而plugins缺少prism,所前端不显示
<script src="{% static 'ckeditor/ckeditor/plugins/prism/lib/prism/prism_patched.min.js' %}"></script>

 

4.转移新linux需要工作

①安装mysql 建立一个yys数据库,在进行source数据库

②安装需要的库,

③__init_pymysel版本需要注意,第三行有可能会变,以后升级mysql(下面报错)

django.core.exceptions.ImproperlyConfigured: mysqlclient 1.4.0 or newer is required; you have 0.10.1.

import pymysql

pymysql.version_info = (1, 4, 13, "final", 0)

pymysql.install_as_MySQLdb()  # 使用pymysql代替mysqldb连接数据库

④进行makemigration

python3 manage.py makemigrations
python3 manage.py migrate

⑤注意prim有没有复制到对应文件夹

注意每次到新的linux需要,prism放到/site-packages/ckeditor/static/ckeditor/ckeditor/plugins 

⑥collectstatic

python manage.py collectstatic