表单.py:
class BetaUser(ModelForm):
Industry = forms.ModelChoiceField(queryset = homepagelaunch_industries.objects.all(), initial=1)
class Meta:
model = BetaUsers
fields = ['Industry']
模型.py
^{pr2}$视图.py
def BetaUserDisplayForm(request):
BetaUserGatherForm = BetaUser(request.POST or None)
if request.method == 'POST':
if BetaUserGatherForm.is_valid():
BetaUserIndustry = BetaUserGatherForm.cleaned_data['Industry']
BetaUserGatherForm.save()
try:
return HttpResponseRedirect('/BetaUserThankYou/')
except:
raise ('Invalid request')
else:
BetaUserGatherForm = BetaUser()
return render(request, 'apage.html', {
'BetaUserGatherForm': BetaUserGatherForm
})
我只是试图从模型类的数据库列IndustryChoice
填充Industry
的值:Industries
。
我做错什么了?有人能帮忙吗?在
Im收到错误:
name 'homepagelaunch_industries' is not defined
谢谢!在
目前没有回答
相关问题 更多 >
编程相关推荐