Last active
February 8, 2019 23:34
-
-
Save KalobTaulien/8a4450c874f97ac49571495b76365f1b to your computer and use it in GitHub Desktop.
Adding a new Subscribers model to the Wagtail ModelAdmin. Tutorial at: https://learnwagtail.com/tutorials/how-register-django-model-wagtails-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
# ... | |
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
# subscribers/admin.py | |
from wagtail.contrib.modeladmin.options import ( | |
ModelAdmin, | |
modeladmin_register, | |
) | |
from .models import Subscribers | |
class SubscriberAdmin(ModelAdmin): | |
"""Subscriber admin.""" | |
model = Subscribers | |
menu_label = "Susbcribers" | |
menu_icon = "placeholder" | |
menu_order = 290 | |
add_to_settings_menu = False | |
exclude_from_explorer = False | |
list_display = ("email", "full_name",) | |
search_fields = ("email", "full_name",) | |
modeladmin_register(SubscriberAdmin) |
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
# subscribers/models.py | |
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): | |
"""Str repr of this object.""" | |
return self.full_name | |
class Meta: # noqa | |
verbose_name = "Susbcriber" | |
verbose_name_plural = "Subscribers" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tutorial: https://learnwagtail.com/tutorials/how-register-django-model-wagtails-modeladmin/
Full Git Commit: CodingForEverybody/learn-wagtail@0026c6f