Пример #1
0
def import_attachments(ad_id):
    try:
        ad = Ad.objects.get(pk=ad_id)
        print(ad)
    except Ad.DoesNotExist:
        return False
    print(ad.url)
    for ur in Crawler.get_attacments_urls(ad.url):
        att = ImageAttachment(ad=ad)
        att.get_remote_image(ur)
Пример #2
0
 def get_photos(ad_id):
     try:
         ad = Ad.objects.get(pk=ad_id)
         print(ad)
     except Ad.DoesNotExist:
         return False
     for img in ad.imageattachment_set.all():
         img.delete()
     if ad.url:
         for ur in Crawler.get_attacments_urls(ad.url):
             att = ImageAttachment(ad=ad)
             att.get_remote_image(ur)