def get_photo_path(instance, filename):
uid = uuid.uuid4().hex
ext = filename.split('.')[-1]
while True:
new_filename = os.path.join('photos', uid[0:2], '%s.%s' % (uid, ext.lower()))
print new_filename
if not os.path.exists(os.path.join(settings.MEDIA_ROOT, new_filename)):
break
return new_filename