Skip to content

Instantly share code, notes, and snippets.

Kalob Taulien KalobTaulien

Block or report user

Report or block KalobTaulien

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@KalobTaulien
KalobTaulien / button-block.css
Created Oct 4, 2019
Wagtail/Draftail button links
View button-block.css
/* Goes into /static/css/button-block.css */
/**
* Add some spacing to the button-section inside of Draftail.
*/
.Draftail-block--button-block {
padding-top: 25px;
padding-bottom: 15px;
border-top: 1px solid #ccc;
border-bottom: 1px solid #ccc;
@KalobTaulien
KalobTaulien / blog models.py
Created Apr 23, 2019
Wagtail: Adding author filtering
View blog models.py
# 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",
@KalobTaulien
KalobTaulien / dev[dot]py
Created Apr 8, 2019
Enabling the Wagtail Styleguide
View dev[dot]py
# dev.py
INSTALLED_APPS = INSTALLED_APPS + [
# ...
'wagtail.contrib.styleguide',
# ...
]
@KalobTaulien
KalobTaulien / home page models
Created Apr 3, 2019
Typing Text On HomePage with Orderable
View home page models
"""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
@KalobTaulien
KalobTaulien / custom_streamfield.py
Created Mar 24, 2019
StructBlock StreamField Validation
View custom_streamfield.py
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)
@KalobTaulien
KalobTaulien / paste into your browsers console
Created Mar 20, 2019
Testing your Wagtail V2 API with JavaScript
View paste into your browsers console
fetch('http://localhost:8000/api/v2/pages/')
.then(res => res.json())
.then(response => console.log(response))
@KalobTaulien
KalobTaulien / staff author_page.html
Created Feb 28, 2019
Getting BlogPostPages by their assigned authors
View staff author_page.html
{% extends 'base.html' %}
{% block content %}
{% for post in posts %}
{{ post.title }}
{% endfor %}
{% endblock %}
@KalobTaulien
KalobTaulien / base.py
Last active Feb 8, 2019
Adding a new Subscribers model to the Wagtail ModelAdmin. Tutorial at: https://learnwagtail.com/tutorials/how-register-django-model-wagtails-modeladmin/
View base.py
# ...
INSTALLED_APPS = [
# ...
'subscribers',
'wagtail.contrib.modeladmin',
# ...
]
# ...
View site_settings models.py
#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."""
@KalobTaulien
KalobTaulien / home models.py
Created Feb 6, 2019
This is the code from the learnwagtail.com lesson where we add an Orderable to the Home Page to create a Bootstrap 4 Carousel.
View home models.py
# home/models.py
from django.db import models
from modelcluster.fields import ParentalKey
from wagtail.admin.edit_handlers import (
FieldPanel,
MultiFieldPanel,
InlinePanel,
StreamFieldPanel,
You can’t perform that action at this time.