I have a model with an optional file field
class MyModel(models.Model):
name = models.CharField(max_length=50)
sound = models.FileField(upload_to= audio/ , blank=True)
让我们拿出价值
>>> test = MyModel(name= machin )
>>> test.save()
我为什么会这样做?
>>> test.sound
<FieldFile: None>
>>> test.sound is None
False
我如何检查是否有一套档案?