自定制插件widget 组件
Posted hude
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了自定制插件widget 组件相关的知识,希望对你有一定的参考价值。
from django.forms.widgets import Radioselect class ColorRadioSelect(RadioSelect): # input_type = ‘radio‘ # template_name = ‘django/forms/widgets/radio.html‘ # option_template_name = ‘django/forms/widgets/radio_option.html‘ template_name = ‘widgets/radio.html‘ option_template_name = ‘widgets/radio_option.html‘
{% with id=widget.attrs.id %} {# 定义id变量 id=widget.attrs.id#} <div{% if id %} id="{{ id }}"{% endif %}{% if widget.attrs.class %} class="{{ widget.attrs.class }}"{% endif %}> {% for group, options, index in widget.optgroups %} {% for option in options %} <label {% if option.attrs.id %}for=" {{ option.attrs.id }}"{% endif %}> {% include option.template_name with widget=option %} </label> {% endfor %} {% endfor %} </div> {% endwith %}
{% include "django/forms/widgets/input.html" %} <span class="cycle" style="background-color:{{ option.label }}"></span>
以上是关于自定制插件widget 组件的主要内容,如果未能解决你的问题,请参考以下文章
Sublime Text自定制代码片段(Code Snippets)