Again, you're creating a global variable and polluting the global namespace. var editor is never used, so I would just replace
```
tpl_preview = django.jQuery('#template_preview')[0];
var editor = CodeMirror.fromTextArea(tpl_preview, {

```
with

```
CodeMirror.fromTextArea(django.jQuery('#template_preview')[0]), {
```