V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
ansheng
V2EX  ›  Python

如何在 Django-admin 后台中添加 markdown 编辑器呢?

  •  
  •   ansheng ·
    anshengme · 2016-12-25 11:20:09 +08:00 · 2253 次点击
    这是一个创建于 2698 天前的主题,其中的信息可能已经有所发展或是发生改变。

    比如我就准备添加simplemde,如果有做过的 V 友,请指导下,正在开发一个博客,编辑器对我来说太重要了,一直都是用markdown语法写文章,富文本编辑器的话,就用这没那么顺手了。

    NaVient
        1
    NaVient  
       2016-12-25 16:48:36 +08:00
    自己写个 admin
    crazycabbage
        2
    crazycabbage  
       2016-12-25 16:58:51 +08:00
    https://www.crazyc.cn/artciles/15/
    用 markdown2 可以把 markdown 解析成 html ,实时显示的话还没有想到什么办法
    ranjiayu
        3
    ranjiayu  
       2016-12-25 17:29:42 +08:00
    先在 settings 中设置下静态文件地址
    admin.py 修改

    ```

    class Media:
    js = (
    'js/jquery.min.js',
    'js/module.min.js',
    'js/hotkeys.min.js',
    'js/simditor.min.js',
    'js/config.js',
    )

    css = {
    'all' : ('css/simditor.css')
    }

    ```

    config.js

    ```

    window.onload = function(){
    var editor = new Simditor({textarea : $('#id_content')});
    }

    ```
    ansheng
        4
    ansheng  
    OP
       2016-12-25 19:47:25 +08:00
    @ranjiayu
    @crazycabbage
    表示在 django 的 admin 添加了一个 markdown 编辑器,左边编辑,右边阅览,前段展示用 js 插件渲染
    chuanqirenwu
        5
    chuanqirenwu  
       2016-12-25 19:53:22 +08:00 via iPhone
    Django pagedown 我感觉是个不错的选择。 simplemde 有一个 django simplemde 的 app ,但我使用中发现一个 bug ,移动端无法输入汉字,查了下相关的 issue ,发现至今没有解决。所以弃用了。
    ansheng
        6
    ansheng  
    OP
       2016-12-25 19:58:00 +08:00
    @chuanqirenwu 我在后台用的就是这个,只不过把默认的编辑器换成`simplemde `的了,前段其他插件渲染
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   3062 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 15:12 · PVG 23:12 · LAX 08:12 · JFK 11:12
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.