スニペットから値を取得する際に問題があります。スニペットセレクタブロックを使用してストリームフィールドに追加しました。Wagtail SnippetChooserBlock in Streamfield
BioSnippet:
@register_snippet
class BioSnippet(models.Model):
name = models.CharField(max_length=200, null=True)
job_title = models.CharField(max_length=200, null=True, blank=True)
bio = RichTextField(blank=True)
image = models.ForeignKey(
'wagtailimages.Image',
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name='+',
verbose_name='Bio Image'
)
contact_email = models.CharField(max_length=50, null=True, blank=True)
contact_phone = models.CharField(max_length=50, null=True, blank=True)
panels = [
FieldPanel('name'),
FieldPanel('job_title'),
FieldPanel('bio'),
ImageChooserPanel('image'),
FieldPanel('contact_email'),
FieldPanel('contact_phone'),
]
def __str__(self):
return self.name
class Meta:
ordering = ['name',]
バイオStreamfield定義:
class BioInline(StructBlock):
bio = SnippetChooserBlock(BioSnippet)
class BioBlock(StructBlock):
overall_title = CharBlock(required=False)
bios = ListBlock(BioInline())
このすべての作品が、私はテンプレートに得るとき、私はスニペット
{% for b in child.value.bios %}
{{ b }}
<hr>
{{ b.name }}
{% endfor %}
の値にアクセスするように見えることはできません
{b}}タグ出力:
bio
Sales Team
しかし、{{b.name}}は何も出力しません。 {{b.values.name}}とか、私が推測できる他の順列もありません。私は値がちょうどプルダウンされていないと思う。 (あなたが実際BioSnippet
オブジェクトを与える)単一のプロパティを持って、bio
-