Tutorial Summary

Most websites have social media icons in their footer and often several other links and icons that are global across the entire website. In this video we explore how to enable that with Wagtails settings context processor.

from django.db import models

from wagtail.admin.edit_handlers import FieldPanel, MultiFieldPanel
from wagtail.contrib.settings.models import BaseSetting, register_setting

class SocialMediaSettings(BaseSetting):
    """Social media settings for our custom website."""

    facebook = models.URLField(blank=True, null=True, help_text="Facebook URL")
    twitter = models.URLField(blank=True, null=True, help_text="Twitter URL")
    youtube = models.URLField(blank=True, null=True, help_text="YouTube Channel URL")

    panels = [
        ], heading="Social Media Settings")
<div class="container">
    <div class="row">
        <div class="col-lg-12 text-center">
            {% if settings.site_settings.SocialMediaSettings.facebook %}
                <a href="{{ settings.site_settings.SocialMediaSettings.facebook }}">
                    <i class="fab fa-facebook-f"></i>
            {% endif %}
            {% if settings.site_settings.SocialMediaSettings.twitter %}
                <a href="{{ settings.site_settings.SocialMediaSettings.twitter }}">
                    <i class="fab fa-twitter"></i>
            {% endif %}
            {% if settings.site_settings.SocialMediaSettings.youtube %}
                <a href="{{ settings.site_settings.SocialMediaSettings.youtube }}">
                    <i class="fab fa-youtube"></i>
            {% endif %}
Sign up for our newsletter

Get notified about new lessons :)

Our Sites