if test.sound.name:
print "I have a sound file"
else:
print "no sound"
Also, FileField‘s boolean value will be False when there’s no file: bool(test.sound) == False when test.sound.name is falsy.
if test.sound.name:
print "I have a sound file"
else:
print "no sound"
Also, FileField‘s boolean value will be False when there’s no file: bool(test.sound) == False when test.sound.name is falsy.