2011-01-04 7 views
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) 

Certains de ces champs sont obligatoires et d'autres non. Pour ceux qui sont requis est-il un moyen que je peux ajouter un astérisque rouge pour dire que ce champ est nécessaire?Comment mettre un astérisque rouge pour afficher un champ obligatoire dans un formulaire en django?

Voici ma forme en 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 %} 
+0

double possible de [Comment rendre champ de formulaire avec des informations qu'il est nécessaire] (http://stackoverflow.com/questions/1254046/how-to-render-form-field- with-information-that-it-required) – gruszczy

+1

Possible copie de [Comment rendre le champ de formulaire avec les informations nécessaires] (http://stackoverflow.com/questions/1254046/how-to-render-form- field-with-information-that-it-required) – hop

Répondre

Questions connexes