def __init__(self, data=None, activity=None, user=None): self.user = user if activity: initial = { 'is_observed': Watching.is_subscribed(activity, user), 'activity': activity.id, } else: initial = None super(SubscribeForm, self).__init__(data, initial=initial)
def save(self): activity = self.cleaned_data['activity'] Watching.subscribe(activity, self.user, self.cleaned_data['is_observed'])