6π
β
bios
here is defined as a list of BioInline
values, and so b
in your template would be a BioInline
value β which has a single property, bio
(giving you the actual BioSnippet
object). To get the name, youβd therefore have to use: {{ b.bio.name }}
.
I donβt think the BioInline
object is actually gaining you anything though β you could instead define BioBlock
as:
class BioBlock(StructBlock):
overall_title = CharBlock(required=False)
bios = ListBlock(SnippetChooserBlock(BioSnippet))
which would make bios
a list of BioSnippet
s β {{ b.name }}
would then work as expected.
π€gasman
0π
Alternatively, you can use self.bios
In blocks.py you have to import the Snippet model (should have this allready):
from thebioapp.models import BioSnippet
And then use this model in the template itself
{% for b in self.bios %}
{{ b }}
<hr>
{{ b.name }}
{% endfor %}
The post is old, but as Wagtail is growing in popularity, I hope this will benefit others!
π€moojen
- [Django]-Django β Models β Recursively retrieve parents of a leaf node
- [Django]-What are these warning for cross-site cookie in my console?
- [Django]-How to get a list of all custom Django commands in a project?
- [Django]-Django, serving static files with nGinx gives error 404
- [Django]-Django β Using F() expression but obtaining non atomic update
Source:stackexchange.com