我想做一个Django应用程序。但我有这个问题。方法是\ u valid()始终返回FALSE。也许问题出在表单.py在tipoAtributo领域,因为当我评论它时,问题解决了。但我需要用这个多重冰场。你知道吗
在表单.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())
在视图.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'))
您可以通过打印错误了解它无效的原因:
将} 。你知道吗
Select
小部件与MultipleChoiceField
一起使用是没有意义的。改用^{相关问题 更多 >
编程相关推荐