Download a remote image and save it to a Django model

后端 未结 6 923
醉话见心
醉话见心 2020-12-01 01:52

I am writing a Django app which will fetch all images of particular URL and save them in the database.

But I am not getting on how to use ImageField in Django.

6条回答
  •  感情败类
    2020-12-01 02:43

    def qrcodesave(request): 
        import urllib2;   
        url ="http://chart.apis.google.com/chart?cht=qr&chs=300x300&chl=s&chld=H|0"; 
        opener = urllib2.urlopen(url);  
        mimetype = "application/octet-stream"
        response = HttpResponse(opener.read(), mimetype=mimetype)
        response["Content-Disposition"]= "attachment; filename=aktel.png"
        return response 
    

提交回复
热议问题