考虑以下 django 模型
class MultiWAN(models.Model):
isp_name = models.CharField(max_length=10)
description = models.TextField(null=True)
ip_address = models.IPAddressField(null=True)
subnet = models.IPAddressField(null=True)
gateway = models.IPAddressField(null=True)
nameserver = models.ForeignKey('NameServer')
weight = models.IntegerField(null=False)
interface = models.CharField(max_length=5)
class NameServer(models.Model):
""" A Isp can have more than one nameserver so far we are declearing a seperate table
"""
name = models.IPAddressField(null=False)
我已经编写了一个相应的视图来获取用户输入并保存到数据库中
def multiwan_info_save(request):
# try:
isp_nm = request.POST['ispname_mw']
desc_mw = request.POST['desc_mw']
ip_address_mw = request.POST['ip_address_mw']
subnet_mw = request.POST['subnet_mw']
nameserver_mw = request.POST.getlist('nameserver_mw')
# nameserver2_mw = request.POST['nameserver2_mw']
gateway_mw = request.POST['gateway_mw']
weight_mw = request.POST['weight_mw']
interface_mw = request.POST['interface_mw']
print "+++++++++++++++================="
print nameserver_mw
nmservr = NameServer()
mv = MultiWAN(isp_name=isp_nm,description=desc_mw,ip_address=ip_address_mw,subnet = subnet_mw,gateway=gateway_mw,weight=weight_mw,interface = interface_mw,nameserver = nameserver_mw)
mv.save()
#except:
当我试图保存时,我收到了上述错误。请帮助我哪里出错了。