def save_related(self, request, form, formsets, change):

        instance = form.instance

        teams_before_save = [team.id for team in instance.team_set.all()]
        LOG.debug("teams for user %s before save: %s" %
                  (instance, teams_before_save))
        super(UserAdmin, self).save_related(request, form, formsets, change)
        teams_after_save = [team.id for team in instance.team_set.all()]
        LOG.debug("teams for user %s after save: %s" %
                  (instance, teams_after_save))

        if cmp(teams_before_save, teams_after_save):
            email_notifications.notify_team_change_for(user=instance)
overrides save_related to send an email if the user team changes
dataset/ETHPy150Open globocom/database-as-a-service/dbaas/account/admin/user.py/UserAdmin.save_related