class Volunteer(models.Model):
def __unicode__(self):
return self.fname + self.lname
fname = models.CharField(max_length=200)
lname = models.CharField(max_length=200)
bio = models.TextField(max_length=400)
number = models.CharField(max_length=15)
email = modesl.CharField(max_length=255)
然后是一个从表单中接收POST数据的视图视图.py地址:
def volunteer_create(request):
if request.method == 'POST'and request.POST['fname'] and request.POST['lname'] and request.POST['email'] (ETC...):
v = Volunteer()
v.fname = request.POST['fname']
v.fname = request.POST['lname']
v.fname = request.POST['email']
v.fname = request.POST['number']
...
v.save()
return HttpResponse("Thank you!") #success!
else
return HttpResponseRedirect("/volunteer_form/") #take them back to the form to fill out missed info
因此,首先需要定义一个模型,在型号.py文件格式如下:
然后是一个从表单中接收POST数据的视图视图.py地址:
然后你需要设置你的网址.py将窗体目标指向此视图。你知道吗
相关问题 更多 >
编程相关推荐