3
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 %}
Shehzad009
  • 1,547
  • 6
  • 28
  • 42
  • possible duplicate of [How to render form field with information that it is required](http://stackoverflow.com/questions/1254046/how-to-render-form-field-with-information-that-it-is-required) – gruszczy Jan 04 '11 at 14:06
  • 1
    Possible duplicate of [How to render form field with information that it is required](http://stackoverflow.com/questions/1254046/how-to-render-form-field-with-information-that-it-is-required) –  Feb 21 '17 at 10:57

1 Answers1

2

How to render form field with information that it is required

Community
  • 1
  • 1
gruszczy
  • 40,948
  • 31
  • 128
  • 181