0
Hello, I created a form with some options to be chosen, follows Forms.py file
class BuscaForm(forms.Form):
FIELDCHOICE = [
('1', 'CNPJ'),
('2', 'Razão Social'),
('3', 'Nome Fantasia'),
('4', 'CNAE'),
('5', 'Descrição CNAE'),
]
valor_consulta = forms.CharField(label='Name')
It follows as I did to access these
{% for value, label in form.fields.campo.choices %}
<option value="{{ value }}" {% if value == form.campo.value %}selected{% endif %} data-option-template='<span class="d-flex align-items-center"><span class="text-truncate">{{ label }}</span></span>'>{{ label }}</option>
{% endfor %}
My idea would be to do something less so(with all the values):
{% if value == '1' %}
<input type="text" id="cnpj" name="{{ form.valor_consulta.html_name }}" size=45 placeholder="Digite o CNPJ que deseja buscar" style="height: 37px">
{% endif %}
But I’m not getting it, there’s some way to do it ?