我安装了模块Django Import / Export link 安装进展顺利。现在,当我想导入扩展名为.xls的文件时,它会显示以下错误:
/ admin / xxxx / xxxx / process_import /中的AttributeError '浮动'没有对象属性' split'
例外位置: C:\ Python34 \ lib \ site-packages \ import_export \ widgets.py in clean,321行
当我在这里编辑文件widgets.py源代码
时private void RadioButton1_CheckedChanged(object sender, EventArgs e)
{
if (RadioButton1.Checked) //If checked == true
{
textBox1.Text = "12";
//example
}
}
以下是321 def clean(self, value):
if not value:
return self.model.objects.none()
if isinstance(value, float):
ids = [int(value)]
else:
ids = value.split(self.separator)
ids = filter(None, value.split(self.separator))
return self.model.objects.filter(**{
'%s__in' % self.field: ids
})
Django模型
ids = filter(None, value.split(self.separator))
Django admin
class Vehicule(models.Model):
matricule = models.CharField(max_length=200)
modele = models.CharField(max_length=200)
annee = models.IntegerField()
def __str__(self):
return self.matricule
class Ligne(models.Model):
nom = models.CharField(max_length=200)
vehicule = models.ManyToManyField(Vehicule, through='Affecter_Vehicule_Ligne')
def __str__(self):
return str(self.nom)
class Affecter_Vehicule_Ligne(models.Model):
vehicule = models.ForeignKey(Vehicule, on_delete=models.CASCADE)
ligne = models.ForeignKey(Ligne, on_delete=models.CASCADE)
actif = models.BooleanField(default=False)
dateAffectation = models.DateTimeField(null=True)
def __str__(self):
return str(self.dateAffectation)
class Arret(models.Model):
nom = models.CharField(max_length=200, null=True)
latitude = models.CharField(max_length=200, null=True)
longitude = models.CharField(max_length=200, null=True)
lignes = models.ManyToManyField(Ligne, through='Ligne_Arret')
def __str__(self):
return str(self.nom)
class Ligne_Arret(models.Model):
sens = models.CharField(max_length=200)
section = models.BooleanField(default=False)
ligne = models.ForeignKey(Ligne, on_delete=models.CASCADE)
arret = models.ForeignKey(Arret, on_delete=models.CASCADE)
def __str__(self):
return str(self.arret)
请帮我解决这个问题???
答案 0 :(得分:0)
您正尝试在此行 AddParameter(SQLCommand, "@IsUser", SqlDbType.Bit, ParameterDirection.Input, obj.IsUser)
我想你可以删除这一行。当您处理ids = filter(None, value.split(self.separator))
案例并在之前拆分时。