Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1import os 

2from django.core.exceptions import ValidationError 

3 

4 

5def validate_file_extension(value): 

6 ext = os.path.splitext(value.name)[1] # [0] returns path+filename 

7 valid_extensions = ['.xml'] 

8 if not ext.lower() in valid_extensions: 8 ↛ 9line 8 didn't jump to line 9, because the condition on line 8 was never true

9 raise ValidationError(u'Unsupported file extension :"{}".'.format(ext.lower()))