html -添加项目符号作为保持器django表单

mbjcgjjk  于 2023-01-06  发布在  Go
关注(0)|答案(2)|浏览(122)

我正在使用django-forms来呈现我的注册页面,我想通过从django-forms中的小部件传递•字符实体来添加一个项目符号作为密码字段的placholder,但它不起作用。x1c 0d1x这是它在浏览器中的呈现方式。
forms.py

class Signup(forms.ModelForm):
    class Meta:
        model = User
        fields = ["username", "email", "password", "password2", "library_no", "first_name", "last_name",]
        help_texts = {
            "username":None,
        }
        labels = {
        }
        widgets = {
            "username": forms.TextInput(attrs={
                "id":"input_46",
                "name":"q46_typeA46",
                "data-type":"input-textbox",
                "class":"form-textbox validate[required]",
                "size":"310",
                "data-component":"textbox",
                "aria-labelledby":"label_46",
                "placeholder":"180591001"
            }),
            "first_name":forms.TextInput(attrs={
                "id":"first_4",
                "name":"q4_name[first]",
                "class":"form-textbox validate[required]",
                "autoComplete":"section-input_4 given-name",
                "data-component":"first", 
                "aria-labelledby":"label_4 sublabel_4_first", 
                "required":True,
                "placeholder":"Chinedu"
            }),
            "last_name":forms.TextInput(attrs={
                "id":"last_4",
                "name":"q4_name[last]", 
                "class":"form-textbox validate[required]", 
                "autoComplete":"section-input_4 family-name",  
                "data-component":"last", 
                "aria-labelledby":"label_4 sublabel_4_last", 
                "required":True,
                "placeholder":"Oladapo Dikko"
            }),
            "email":forms.EmailInput(attrs={
                "id=":"input_10", 
                "name":"q10_email10",
                "class":"form-textbox validate[required, Email]", 
                "placeholder":"ex: myname@example.com",
                "data-component":"email", 
                "aria-labelledby":"label_10 sublabel_input_10",
                "required":True
            }),
            "password": forms.PasswordInput(attrs={
                "id":"first_50", 
                "name":"q50_name50[first]",
                "class":"form-textbox",  
                "autoComplete":"section-input_50 given-name",  
                "data-component":"first", 
                "aria-labelledby":"label_50 sublabel_50_first", 
                "required":True,
                "placeholder":"••"
            }),
            "password2": forms.PasswordInput(attrs={
                "id":"last_50", 
                "name":"q50_name50[last]",
                "class":"form-textbox", 
                "autoComplete":"section-input_50 family-name",
                "data-component":"last", 
                "aria-labelledby":"label_50 sublabel_50_last",
                "required": False
            }),
            "library_no": forms.TextInput(attrs={"required": False}),
        }

signup.html

<!DOCTYPE html>
<html class="supernova">
<head>
    <title>SignUp</title>
    <style type="text/css">@media print{.form-section{display:inline!important}.form-pagebreak{display:none!important}.form-section-closed{height:auto!important}.page-section{position:initial!important}}</style>
    <link rel="stylesheet" href="/static/signup/css/style.css">
    <link rel="stylesheet" href="/static/signup/css/main.css">
</head>
<body>
<form class="jotform-form" action="/signup/" method="post" name="form_230023299150548" id="230023299150548" accept-charset="utf-8" autocomplete="on">
    {%csrf_token%}
  <div role="main" class="form-all">
    <style>
      .form-all:before
      {
        background: none;
      }
    </style>
    <ul class="form-section page-section">

      <li id="cid_28" class="form-input-wide" data-type="control_head">
        <div class="form-header-group  header-large">
          <div class="header-text httal htvam">
            <h1 id="header_28" class="form-header" data-component="header">SignUp</h1>
          </div>
        </div>
      </li>

      <li class="form-line jf-required" data-type="control_textbox" id="id_46">
        <label class="form-label form-label-top form-label-auto" id="label_46" for="input_46"> Username
            <span class="form-required">*</span> 
        </label>

        <div id="cid_46" class="form-input-wide jf-required" data-layout="half"> 
            {{form.username}}
        </div>
      </li>

      <li class="form-line jf-required" data-type="control_fullname" id="id_4">
        <div id="cid_4" class="form-input-wide jf-required" data-layout="full">
            <div data-wrapper-react="true">
                <span class="form-sub-label-container" style="vertical-align:top" data-input-type="first">
                                    <label class="form-label form-label-top" id="label_4" for="first_4"> First Name
                                        <span class="form-required">*</span> 
                                    </label>
                  {{form.first_name}}
                </span>

                <span class="form-sub-label-container" style="vertical-align:top" data-input-type="last">
                                    <label class="form-label form-label-top" id="label_4" for="first_4"> Last Name
                                        <span class="form-required">*</span> 
                                    </label>
                                    {{form.last_name}}
                </span>
            </div>
        </div>
      </li>

      <li class="form-line jf-required" data-type="control_email" id="id_10">
        <label class="form-label form-label-top form-label-auto" id="label_10" for="input_10"> E-mail
            <span class="form-required">*</span> 
        </label>
        <div id="cid_10" class="form-input-wide jf-required" data-layout="half"> 
            <span class="form-sub-label-container" style="vertical-align:top">
                                {{form.email}}
            </span> 
        </div>
      </li>
      
      <li class="form-line" data-type="control_fullname" id="id_50">
        <div id="cid_50" class="form-input-wide" data-layout="full">
            <div data-wrapper-react="true">
                <span class="form-sub-label-container" style="vertical-align:top" data-input-type="first">
                                        <label class="form-label form-label-top form-label-auto" id="label_50" for="first_50"> Password 
                                            <span class="form-required">*</span> 
                                        </label>
                    {{form.password}}
                </span>

                <span class="form-sub-label-container" style="vertical-align:top" data-input-type="last">
                                        <label class="form-label form-label-top form-label-auto" id="label_50" for="first_50">Confirm Password 
                                            <span class="form-required">*</span> 
                                        </label>
                    {{form.password2}}
                </span>
            </div>
        </div>
      </li>

基本上,我想知道的是是否可以从django-forms中传递一个项目符号占位符,以及如何进行。
因此,我检查了源代码,发现placholder值呈现为&amp;bull;,而不是&bull;
那么,如何才能确保它保持&bull;

blmhpbnm

blmhpbnm1#

您可以使用以下两个实体代码之一将项目符号添加为占位符:第一个月

"password": forms.PasswordInput(attrs={
                        "id":"first_50", 
                        "name":"q50_name50[first]",
                        "class":"form-textbox",  
                        "autoComplete":"section-input_50 given-name",  
                        "data-component":"first", 
                        "aria-labelledby":"label_50 sublabel_50_first", 
                        "required":True,
                        "placeholder":"&#x2022"
                    }),
qeeaahzv

qeeaahzv2#

我在这个Website上找到了python的unicode编码
Here is my forms.py

class Signup(forms.ModelForm):
    class Meta:
        model = User
        fields = ["username", "email", "password", "password2", "library_no", "first_name", "last_name",]
        help_texts = {
            "username":None,
        }
        labels = {
        }
        widgets = {
            "password": forms.PasswordInput(attrs={
                "id":"first_50", 
                "name":"q50_name50[first]",
                "class":"form-textbox",  
                "autoComplete":"section-input_50 given-name",  
                "data-component":"first", 
                "aria-labelledby":"label_50 sublabel_50_first", 
                "required":True,
                "placeholder":"\u2022"
            }),
        }

相关问题