class BlogPage(Page):
date = models.DateField("Post date",blank=True,null=True)
body = StreamField([
('heading', blocks.CharBlock(form_classname="full title")),
('paragraph', blocks.RichTextBlock()),
('image', ImageChooserBlock()),
])
tags = ClusterTaggableManager(through=ImmigrationPageTag, blank=True)
search_fields = Page.search_fields + [
index.SearchField('body'),
index.FilterField('date'),
]
api_fields = [
APIField('date'),
APIField('body'),
]
content_panels = Page.content_panels + [
MultiFieldPanel([
FieldPanel('date'),
FieldPanel('tags'),
], heading="Article information"),
StreamFieldPanel('body', classname="full"),
]
and Api output :
{
"meta": {
"total_count": 1
},
"items": [
{
"id": 3,
"meta": {
"type": "blogs.BlogPage",
"detail_url": "
http://localhost/api/v2/pages/3/",
"html_url": null,
"slug": "first-demo-page",
"first_published_at": "2021-11-29T04:49:57.108466Z"
},
"title": "First Demo page",
"body": [
{
"type": "heading",
"value": "Heading 1",
"id": "c7e5a53c-1fad-43cf-9cad-1de46b6c6d2a"
},
{
"type": "paragraph",
"value": "<p data-block-key=\"pba9n\">Write Here paragraph</p>",
"id": "f3888bd0-cfa2-445f-9309-82752515457c"
},
{
"type": "image",
"value": 1,
"id": "0e7279ee-c82f-40dd-9a01-f1767144c74a"
}
]
}
]
}
Note: so how can i get the path of image in api output {
"type": "image",
"value": 1,
"id": "0e7279ee-c82f-40dd-9a01-f1767144c74a"
}