python - django codemirror 从编辑器获取代码

标签 python django codemirror

下面是我在模板中的代码编辑器的代码

{% load static %}
<script src="{% static 'codemirror.js' %}"></script>
<link rel="stylesheet" href="{% static 'codemirror.css' %}">
<script src="{% static 'clike.js' %}"></script>

<script>

var myCodeMirror = CodeMirror(document.getElementById('text_area'), {
  value: "int main()",
  mode: "text/x-c++src",
  lineNumbers: true,
  indentUnit: 4,
});
</script>

使用div标签

<div id="text_area" name="text_area" style="margin-top: 0px;" ></div>

如何通过 post 方法获取提交按钮后的代码?

注意: 我正在使用 github 中的 CodeMirror 库

最佳答案

您应该能够通过

获取代码
myCodeMirror.getValue()

关于python - django codemirror 从编辑器获取代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41414243/

相关文章:

javascript - 修改Ajax.org Cloud9 Editor(Ace Editor)的装订线

python - 如何使用反射或解析读取Python类中声明成员的顺序(禁止元类替换)?

python - Seaborn Jointplot 为每个类添加颜色

python - 列出有向图中顶点属于单个簇的所有路径

python - Django 在使用 matplotlib 示例时出错

python - 在我的家用电脑上加载一个 django 项目

mysql - Makemigrations值错误: too many values to unpack

reactjs - ClojureScript:如何使用 Reagent react 性地更改 CodeMirror

javafx - 使用 java 使用 setvalue 在基于 codemirror 的编辑器中加载文件时出现 JSException

python - 为什么对于整数而不是 float ,ndigits=None 上的 round 加注?