我正在为 StreamField 创建一个 StructBlock。目标是创建一个可以上传图像以及大量元数据的块。元数据是 CharBlocks、ImageChooserBlocks 和 RichTextBlocks 的混合体。
当我想使用我在数据库中进行更改时, makemigrations
我收到错误“ValueError:要解压的值太多(预期为 2)”
在此之前我得到:
File "C:...\models.py", line 66, in CatalogueIndexPage
'image', TurnerImageBlock(),
File "C:...\wagtail\lib\site-packages\wagtail\wagtailcore\fields.py", line 51, in __init__
self.stream_block = StreamBlock(block_types, required=not self.blank)
File "C:...\wagtail\lib\site-packages\wagtail\wagtailcore\blocks\stream_block.py", line 47, in __init__
for name, block in local_blocks:
我在想这可能是由于太多的领域。但这应该不是问题。我也看过格式,但看不到任何内容。我已经包含了models.py
下面的代码。
from datetime import date
from wagtail.wagtailcore.models import Page
from wagtail.wagtailcore.fields import StreamField
from wagtail.wagtailcore import blocks
from wagtail.wagtailadmin.edit_handlers import StreamFieldPanel
from wagtail.wagtailimages.blocks import ImageChooserBlock
class TurnerImageBlock(blocks.StructBlock):
image_title = blocks.CharBlock(required=True)
thumbnail = ImageChooserBlock()
full_image = ImageChooserBlock()
copyright_conditions_of_use = blocks.CharBlock()
unique_identifying_number = blocks.CharBlock()
date_of_submission = blocks.DateTimeBlock(default=date.today)
# person submitting
person_submitting_images = blocks.CharBlock()
current_owning_inst_person = blocks.CharBlock()
inst_personal_unique_impression_accession_no = blocks.CharBlock()
inst_personal_unique_image_accession_no = blocks.CharBlock()
# Dimensions
impression_physical_dimensions = blocks.CharBlock()
size_of_paper = blocks.CharBlock()
size_of_plate_impression = blocks.CharBlock()
size_of_picture = blocks.CharBlock()
# Physical Attributes
paper_type = blocks.CharBlock()
comments_on_impression = blocks.RichTextBlock()
condition = blocks.CharBlock()
physical_history = blocks.CharBlock()
# Digital Image
digital_image_dimensions = blocks.CharBlock()
digital_image_capture_mechanism = blocks.CharBlock()
imaging_device = blocks.CharBlock()
device_settings = blocks.CharBlock()
calibration = blocks.CharBlock()
date_of_capture = blocks.CharBlock()
# Engraving info
rawlinson_finerg_number = blocks.CharBlock()
proposed_version_state = blocks.CharBlock()
engraver = blocks.CharBlock()
original_engraving_date = blocks.CharBlock()
original_publication = blocks.CharBlock()
actual_publication = blocks.CharBlock()
# text and info on impression
printed_text_on_impression = blocks.RichTextBlock()
written_info_on_impression = blocks.RichTextBlock()
turner_touching_comments = blocks.RichTextBlock()
previous_collection_owner = blocks.RichTextBlock()
links_related_info = blocks.CharBlock()
histories_or_original_drawing = blocks.CharBlock()
class CatalogueIndexPage(Page):
body = StreamField([
'image', TurnerImageBlock(),
])
content_panels = Page.content_panels + [
StreamFieldPanel('body'),
]
我见过类似的问题,说这是字典/元组等错误。但是我没有足够的经验来了解我的代码中的问题所在。