我有一个模型产品Django模块返回NoneType
它有两个字段的大小等等
colours = models.CharField(blank=True, null=True, max_length=500)
size = models.CharField(blank=True, null=True, max_length=500)
在我看来,我有
current_product = Product.objects.get(slug=title)
if len(current_product.size) != 0 :
current_product.size = current_product.size.split(",")
,并得到这个错误&颜色:
'NoneType'类型的对象没有len()
什么是NoneType?我该如何测试它?
“类型为NoneType的对象”是您可以在Python文档中查找的东西。这是不变的无。该模型不返回“NoneType”,它返回None,它是NoneType的一个对象。 – 2009-02-16 11:17:36