View models.py
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
from wagtail.core.models import Page | |
from wagtail.core import blocks | |
from wagtail.images.blocks import ImageChooserBlock | |
class NestedSidebarContent(blocks.StructBlock): | |
sidebar_alignment = blocks.ChoiceBlock(choices=( | |
("left", "Left"), | |
("right", "Right"), | |
)) | |
main_content2 = blocks.StreamBlock([ |
View blog models.py
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", |
View dev[dot]py
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', | |
# ... | |
] |
View home page models
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 |
View custom_streamfield.py
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
from django.core.exceptions import ValidationError | |
from django.forms.utils import ErrorList | |
from wagtail.core import blocks | |
class CTABlock(blocks.StructBlock): | |
"""A simple call to action section.""" | |
button_url = blocks.URLBlock(required=False) |
View paste into your browsers console
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)) |
View base.py
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', | |
# ... | |
] | |
# ... |
View site_settings models.py
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
#site_settings/models.py | |
from django.db import models | |
from wagtail.admin.edit_handlers import FieldPanel, MultiFieldPanel | |
from wagtail.contrib.settings.models import BaseSetting, register_setting | |
@register_setting | |
class SocialMediaSettings(BaseSetting): | |
"""Social media settings for our custom website.""" |
NewerOlder