How to put a red asterisk to show the required field in the 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 needed, is there a way I can add a red star to say that this field is not required?

Here is my html form.

{% 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 %}
+3
source share

Source: https://habr.com/ru/post/1783407/


All Articles