The idea for this lesson is to eventually have a blog, where you’ll want subscribers. So we will create a subscriber model.

from django.db import models

class Subscribers(models.Model):
    """A subscriber model."""

    email = models.CharField(max_length=100, blank=False, null=False, help_text="Email address")
    full_name = models.CharField(max_length=100, blank=False, null=False, help_text="First and Last Name")

    def __str__(self):
        return self.full_name

After migrating, we won’t see this is wagtail’s admin page! WE want to add a new tab to the sidebar that allows us to edit normal django models like we can with wagtail pages.

Untitled

We now have access to subscibers on the toolbar! But if we click it we will get an error:

TemplateDoesNotExist at /admin/UserProfileApp/subscriber/

This is because modeladmin is not installed with wagtail by defaul.

INSTALLED_APPS = [
    "home",
    "search",
    "flex",
    "streams",
    "wagtail.contrib.forms",
    "wagtail.contrib.redirects",
    "wagtail.contrib.settings",
    "wagtail.contrib.modeladmin",

Untitled

Untitled

You can now alter fields inside of the wagtail admin interface :)

You can also add them as a separate group in the sidebar:

class UserManagementGroup(ModelAdminGroup):
    menu_label = 'User Management'
    menu_icon = 'group'  # change as required
    menu_order = 200  # will put in 3rd place (000 being 1st, 100 2nd)
    items = (SubscriberAdmin,)

modeladmin_register(UserManagementGroup)

Untitled