This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# demo/blocks.py; or sterams/blocks.py | |
"""Stream Blocks.""" | |
from wagtail.core import blocks | |
class CustomRichTextBlock(blocks.StructBlock): | |
"""Rich text content.""" | |
richtext_content = blocks.RichTextBlock(required=True) | |
bg_color = blocks.ChoiceBlock(required=True, choices=[ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# flex/models.py | |
"""Flexible page.""" | |
from django.db import models | |
from wagtail.admin.edit_handlers import FieldPanel, StreamFieldPanel | |
from wagtail.core.fields import StreamField | |
from wagtail.core.models import Page | |
from streams import blocks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# home/models.py | |
from django.db import models | |
from modelcluster.fields import ParentalKey | |
from wagtail.admin.edit_handlers import ( | |
FieldPanel, | |
MultiFieldPanel, | |
InlinePanel, | |
StreamFieldPanel, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ... | |
INSTALLED_APPS = [ | |
# ... | |
'subscribers', | |
'wagtail.contrib.modeladmin', | |
# ... | |
] | |
# ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fetch('http://localhost:8000/api/v2/pages/') | |
.then(res => res.json()) | |
.then(response => console.log(response)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Home page.""" | |
from django.db import models | |
from modelcluster.fields import ParentalKey | |
from wagtail.admin.edit_handlers import ( | |
FieldPanel, | |
InlinePanel, | |
MultiFieldPanel, | |
) | |
from wagtail.core.models import Orderable, Page |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# dev.py | |
INSTALLED_APPS = INSTALLED_APPS + [ | |
# ... | |
'wagtail.contrib.styleguide', | |
# ... | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# blog/models.py | |
# Nothing in this class has changed. I just put it here for reference. | |
class BlogAuthor(models.Model): | |
"""Blog author for snippets.""" | |
name = models.CharField(max_length=100) | |
website = models.URLField(blank=True, null=True) | |
image = models.ForeignKey( | |
"wagtailimages.Image", |