简体   繁体   中英

How do I put a a red asterisk to show a required field in a form in django?

class ClientForm(forms.ModelForm):
    client_number = forms.IntegerField()
    name = forms.CharField(max_length=80)
    address = forms.CharField(max_length=250)
    telephone = forms.CharField(max_length=20)
    fax = forms.CharField(max_length=20)
    email = forms.EmailField()
    alternative_name = forms.CharField(max_length=80, required=False)
    alternative_address = forms.CharField(max_length=250, required=False)
    alternative_telephone = forms.CharField(max_length=20, required=False)
    alternative_email = forms.EmailField(required=False)

Some of these fields are required and some are not. For those that are required is there a way which I can add a red asterisk to say that this field is required?

Here is my form in html.

{% extends "base.html" %}

{% block content %}
<font>
<h3>Add Client</h3>
</font>
    <form method= "POST" action="">
        <font>
        <div id="form">
        <table>
            {{form.as_table}}
        </table>
        <div>
        <input type="submit" value="Save" STYLE="background-color:#E8E8E8; color:#181818 "/>
        </div>
        </div>
    </form>
{% endblock %}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM