From 15fdfeb43a74f87940b0ed9643e4d27d8fba94c9 Mon Sep 17 00:00:00 2001 From: doubaniux Date: Tue, 12 May 2020 14:37:12 +0800 Subject: [PATCH] fix book form cover url error again --- common/forms.py | 6 ++++-- common/scraper.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/common/forms.py b/common/forms.py index 15180200..1403257a 100644 --- a/common/forms.py +++ b/common/forms.py @@ -2,7 +2,6 @@ from django import forms from django.contrib.postgres.forms import JSONField from django.core.exceptions import ValidationError from django.utils.translation import gettext_lazy as _ -from boofilsic.settings import MEDIA_URL import json @@ -67,7 +66,10 @@ class ImageInput(forms.FileInput): Return the file object if it has a defined url attribute. """ if self.is_initial(value): - return MEDIA_URL + value + if value.url: + return value.url + else: + return def is_initial(self, value): """ diff --git a/common/scraper.py b/common/scraper.py index 6c5a5cc6..3b1ff5cc 100644 --- a/common/scraper.py +++ b/common/scraper.py @@ -101,7 +101,7 @@ def scrape_douban_book(url): 'cache-control': 'no-cache', 'dnt': '1' , }, - # proxies=proxies, + proxies=proxies, timeout=TIMEOUT, ) if img_response.status_code == 200: