zoukankan      html  css  js  c++  java
  • 自定制插件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'
    widget.py
    {% 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 %}
    radio.html
    {% include "django/forms/widgets/input.html" %}
    <span class="cycle" style="background-color:{{ option.label }}"></span>
    radio_option.html
  • 相关阅读:
    [.NET学习]抽象&#
    几个国内开源
    通过C#命令行&#
    我的宝贝
    我的新博客
    常用的在线网
    收集一些.NET开
    论研究生学术
    在vs2008里安装使&#
    c#编码好习惯
  • 原文地址:https://www.cnblogs.com/hude/p/12826055.html
Copyright © 2011-2022 走看看