How to save an Image using URL in python/django
Question: If you were to save an Image using it's URL how would you do it ?

Also how do I give the Image a unique file name while saving it.

    
    
        response = urllib.urlopen(image_url)
        file_name = ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(10))
        f = open('/media/images/temp/'+file_name, "wb")
        f.write(response.read())
        f.close()
    

It throws no error nor saves the file... I'm new to this I have no clue what
is going wrong : |


Answer: 
    import urllib
    import string
    import random
    import os
    
    filename_charset = string.ascii_letters + string.digits
    filename_length = 10
    file_save_dir = '/home/user/download/'
    
    filename = ''.join(random.choice(filename_charset)
                       for s in range(filename_length))
    
    urllib.urlretrieve ("http://www.example.com/image.png", 
                        os.path.join(file_save_dir, filename + '.png'))
    

