zoukankan      html  css  js  c++  java
  • django中form的CSS样式

    On a real web page, you probably don't want every widget to look the same. You might want a larger input element for the comment, and you might want the 'name' widget to have some special CSS class. To do this, you use the attrs argument when creating the widget:

    Widget.attrs

    For example:

    class CommentForm(forms.Form):
    name = forms.CharField(
    widget=forms.TextInput(attrs={'class':'special'}))
    url = forms.URLField()
    comment = forms.CharField(
    widget=forms.TextInput(attrs={'size':'40'}))

    Django will then include the extra attributes in the rendered output:

    >>> f = CommentForm(auto_id=False)
    >>> f.as_table()
    <tr><th>Name:</th><td><input type="text" name="name" class="special"/></td></tr>
    <tr><th>Url:</th><td><input type="text" name="url"/></td></tr>
    <tr><th>Comment:</th><td><input type="text" name="comment" size="40"/></td></tr>
  • 相关阅读:
    枚举
    泛型
    装箱和拆箱
    使用TryParse()来执行数值转换
    参数数组
    checked和unchecked转换
    字符串不可变
    TCC : Tiny C Compiler (2018-2-6)
    win10 下 protobuf 与 qt
    QWebView 与Js 交互
  • 原文地址:https://www.cnblogs.com/lddhbu/p/2519339.html
Copyright © 2011-2022 走看看