def clean_image_extension(form_field):
 if form_field:
  if ('.' not in form_field.name):
   raise ValidationError(MSG_IMAGE_EXTENSION)
  (_, ext) = form_field.name.rsplit('.', 1)
  if (ext.lower() not in ALLOWED_IMAGE_EXTENSIONS):
   raise ValidationError(MSG_IMAGE_EXTENSION)

def clean_image_extension ( form_field ) : if form_field : if ( '.' not in form_field . name ) : raise ValidationError ( MSG_IMAGE_EXTENSION ) ( _ , ext ) = form_field . name . rsplit ( '.' , 1 ) if ( ext . lower ( ) not in ALLOWED_IMAGE_EXTENSIONS ) : raise ValidationError ( MSG_IMAGE_EXTENSION )
ensure only images of certain extensions can be uploaded .