'Why the name of the form variable is being displayed? django
I have this form
form.py
from django import forms
from .models import User
LETTERS= [
('a', 'a)'),
('b', 'b)'),
('c', 'c)'),
('d', 'd)'),
('e', 'e)'),
]
class CHOICES(forms.Form):
NUMS = forms.ChoiceField(widget=forms.RadioSelect, choices=LETTERS)
and this view views.py
from django.shortcuts import render
from questoes.models import Questao
from .forms import CHOICES
# Create your views here.
def prova(request):
questoes = Questao.objects.order_by('?')[:5]
form = CHOICES
if request.method=='POST':
dados = {
'questoes': questoes,
'form':form(request.POST)
}
return render(request,'provas/prova.html', dados)
else:
dados = {
'questoes': questoes,
'form':form
}
return render(request,'provas/prova.html', dados)
I can't figure out why the name NUMS (the form's variable name) is being rendered in the HTML. :(
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

