Asset tag renderer

class djangocodemirror.templatetags.djangocodemirror_tags.CodemirrorAssetTagRender[source]

Bases: djangocodemirror.manifest.CodeMirrorManifest

A manifest extend to render Codemirror assets tags HTML.

codemirror_html(config_name, varname, element_id)[source]

Render HTML for a CodeMirror instance.

Since a CodeMirror instance have to be attached to a HTML element, this method requires a HTML element identifier with or without the # prefix, it depends from template in settings.CODEMIRROR_FIELD_INIT_JS (default one require to not prefix with #).

  • config_name (string) – A registred config name.
  • varname (string) – A Javascript variable name.
  • element_id (string) – An HTML element identifier (without leading #) to attach to a CodeMirror instance.

HTML to instanciate CodeMirror for a field input.

Return type:



Render HTML tags for Javascript assets.

Returns:HTML for CSS assets from every registered config.
Return type:string

Render HTML tags for Javascript assets.

Returns:HTML for Javascript assets from every registered config.
Return type:string

Register config name from field widgets

Parameters:*args – Fields that contains widget djangocodemirror.widget.CodeMirrorWidget.
Returns:List of registered config names from fields.
Return type:list
render_asset_html(path, tag_template)[source]

Render HTML tag for a given path.

  • path (string) – Relative path from static directory.
  • tag_template (string) – Template string for HTML tag.

HTML tag with url from given path.

Return type:



Given a Field or BoundField, return widget instance.


Raise an exception if given field object does not have a widget.

Parameters:field (Field or BoundField) – A field instance.
Returns:Retrieved widget from given field.
Return type:django.forms.widgets.Widget