I have an Account model that extends django's custom User model:
class Account(models.Model):
    user = models.OneToOneField(User, on_delete=models.CASCADE)
    joined_groups = models.ManyToManyField(Group, related_name='joined_group', blank=True)
    created_groups = models.ManyToManyField(Group, blank=True)
    EMAIL_PREFERENCES = [
        ('user_emails', 'User Emails'),
        ('group_emails', 'Group Emails'),
        ('leader_emails', 'Leader Emails'),
    ]
    email_preferences = MultiSelectField(
        verbose_name = 'Email Preferences',
        choices=EMAIL_PREFERENCES,
        blank=True,
        max_choices=3,
        max_length=255,
    )
When a User registers or signs up, as of now, they create a connected Account with the same id and pk with the fields of joined_groups and created_groups empty. However, they also have none of the email_preferences selected either. Here in lies my issue.
I want a User who signs up to have the default for email_preferences true for all of them. Then, if they prefer to not receive any emails, they can edit their email_preferences on their Account page.
Lastly, once the email_preferences have been selected, I need to add the conditional into the view to see whether or not this User should receive email notifications:
For when a User creates a Group:
class CreateGroup(CreateView):
    model = Group
    form_class = GroupForm
    template_name = 'create_group.html'
    def form_valid(self, form):
        group = form.save()
        group.joined.add(self.request.user)
        account = self.request.user.account
        account.created_chaburahs.add(group)
        account.joined_chaburahs.add(group)
        email = account.user.email
        # celery task to send email
        create_group_notification_task.delay(email)
        return HttpResponseRedirect(reverse('group_detail', args=[str(group.pk)]))
My isssue regarding this is I don't know how to access the right condition. If the User allows Leader (the head of a Group) Emails, the they should receive an email notifying them on creating a Group. But how do I access that condition?
Is it like an array? Is it if email_preferences.leader_emails == True? Or is it a different syntax entirely?