def form_valid(self, form):
    form.instance.site = get_current_site(self.request)
    response = super(ProjectCreateView, self).form_valid(form)
    tasks = Task.objects.filter_current_site().filter_group(self.request.user).filter_availability(self.request.user)
    for task in tasks:
        form.instance.tasks.add(task)
    views = View.objects.filter_current_site().filter_catalog(self.object.catalog).filter_group(self.request.user).filter_availability(self.request.user)
    for view in views:
        form.instance.views.add(view)
    membership = Membership(project=form.instance, user=self.request.user, role='owner')
    membership.save()
    return response
def form_valid(self, form):
    form.instance.site = get_current_site(self.request)
    response = super(ProjectCreateView, self).form_valid(form)
    tasks = Task.objects.filter_current_site().filter_group(self.request.user).filter_availability(self.request.user)
    for task in tasks:
        form.instance.tasks.add(task)
    views = View.objects.filter_current_site().filter_catalog(self.object.catalog).filter_group(self.request.user).filter_availability(self.request.user)
    for view in views:
        form.instance.views.add(view)
    membership = Membership(project=form.instance, user=self.request.user, role='owner')
    membership.save()
    return response