I am new to Django. Now I have class defined below
PROPERTY_TYPE_CHOICE = [[ 1 , Fixed (TODO) ],
[ 2 , Trajectory (TODO) ],
[ 3 , Error_Detecting ],
[ 4 , Error_Correcting ]]
FIXED_TYPE_CHOICE = [[ 1 , Prefix ,
2 , Suffix ]]
class UploadFileForm(forms.Form):
# title = forms.CharField(max_length=50)
automata_file = forms.FileField(required = True)
transducer_file = forms.FileField(required = True)
property_type = forms.ChoiceField(choices=PROPERTY_TYPE_CHOICE,
required=True)
fixed_type = forms.ChoiceField(choices=FIXED_TYPE_CHOICE,
required=True)
debug_output = forms.BooleanField(required=False)
我有一个Property_TYPE_CHOICE 展示在前面的 html
<div class="fieldWrapper">
{{ form.property_type.errors }}
<label for="id_a">Select <u>a type</u> of property:</label>
{{ form.property_type }}
</div>
and I want to show the FIXED_TYPE_CHOICE if I choose the first choice "Fixed (TODO)" in the PROPERTY_TYPE_CHOICE. I read the docs about Django, and I think it may be implemented in this way:
<div class="fieldWrapper">
{{ form.property_type.errors }}
<label for="id_a">Select <u>a type</u> of property:</label>
{{ form.property_type }}
</div>
{% if form.property_type== 1 %}
<div class="fieldWrapper">
{{ form.fixed_type.errors }}
<label for="id_a">Select <u>a fixed type</u> of property:</label>
{ { form.fixed_type }}
</div>
{% endif %}
But I can t do that. What should I do? Thank you.