Fix ISBN scraper
This commit is contained in:
parent
4928b555b7
commit
079ade9bbb
|
@ -9,6 +9,7 @@ import unicodedata
|
|||
from urllib.error import HTTPError
|
||||
import urllib.request
|
||||
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.db.models import QuerySet
|
||||
from django.forms import ModelForm
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
@ -320,6 +321,13 @@ class MediaAdminForm(ModelForm):
|
|||
return self.cleaned_data
|
||||
|
||||
def _clean_fields(self):
|
||||
# First clean ISBN field
|
||||
isbn_field = self.fields['isbn']
|
||||
isbn = isbn_field.widget.value_from_datadict(
|
||||
self.data, self.files, self.add_prefix('isbn'))
|
||||
isbn = isbn_field.clean(isbn)
|
||||
self.cleaned_data['isbn'] = isbn
|
||||
|
||||
for name, field in self.fields.items():
|
||||
# value_from_datadict() gets the data from the data dictionaries.
|
||||
# Each widget type knows how to retrieve its own data, because some
|
||||
|
@ -329,7 +337,6 @@ class MediaAdminForm(ModelForm):
|
|||
else:
|
||||
value = field.widget.value_from_datadict(
|
||||
self.data, self.files, self.add_prefix(name))
|
||||
from django.core.exceptions import ValidationError
|
||||
try:
|
||||
# We don't want to check a field when we enter an ISBN.
|
||||
if "isbn" not in self.data \
|
||||
|
|
Loading…
Reference in New Issue