def get_forms(self, form_classes):
        forms = super(UserUpdateView, self).get_forms(form_classes)
        if not self.object.groups_moderating.exists():
            del forms['user_form'].fields['receive_group_join_notifications']
        return forms
Get forms.
dataset/ETHPy150Open ofa/connect/open_connect/accounts/views.py/UserUpdateView.get_forms