Bir Django uygulaması yapmaya çalışıyorum. Ama bu problemim var. yöntem is_valid() daima FALSE döndürür. Belki de problem, tipoAtributo alanındaki forms.py'dir, çünkü yorum yaptığımda sorun çözülmüştür. ama bu MultipleChoiceField'ı kullanmam gerekiyor.Django: Form yöntemi is_valid() her zaman FALSE döner
forms.py
class tipoAtribute(forms.Form):
nombreAtribute = forms.CharField(max_length = 25)
CHOICES = (
('Categorico', 'Categorico'),
('NUMERICO', 'NUMERICO'))
tipoAtributo = forms.MultipleChoiceField(choices = CHOICES, required=True, widget=forms.Select())
views.py
def createTables(request):
if request.method == 'POST':
form = tipoAtribute(request.POST or None)
if form.is_valid():
print "Soy una bandera boba"
nombreAtribute = form.cleaned_data['nombreAtribute']
tipoAtributo = form.cleaned_data['tipoAtributo']
cursor = connection.cursor()
cursor.execute("use " + nombreProyecto)
cursor.execute("CREATE TABLE "+ nombreProyecto + "(prueba VARCHAR(25))")
return HttpResponseRedirect(reverse('index'))
return HttpResponseRedirect(reverse('index'))