from django import forms from .models import NotificationCategoryChoices, PushNotification class PushNotificationForm(forms.ModelForm): class Meta: model = PushNotification fields = [ "title", "notification_category", # "banner_image", "principal_type", "message", ] widgets = { "message": forms.Textarea(attrs={"rows": 4}), } def __init__(self, *args, **kwargs): super(PushNotificationForm, self).__init__(*args, **kwargs) # Limit choices for notification_category to GENERAL and PROMOTIONS only self.fields["notification_category"].choices = [ (NotificationCategoryChoices.GENERAL, "General"), (NotificationCategoryChoices.PROMOTIONS, "Promotions"), ]