fix book form cover url error again
This commit is contained in:
parent
41b0591d16
commit
15fdfeb43a
2 changed files with 5 additions and 3 deletions
|
@ -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):
|
||||
"""
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Add table
Reference in a new issue