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>
  • 相关阅读:
    Document
    Document
    Document
    Document
    Document
    Document
    8. vue 的生命周期
    7. vue-cli 安装和使用脚手架
    5.组件(2) 之 父级传子级
    6.组件(3) 之 子级传父级
  • 原文地址:https://www.cnblogs.com/lddhbu/p/2519339.html
Copyright © 2011-2022 走看看