def register(self, request, form_class): new_user = super(MyRegistrationView, self).register(request, form_class) g = Group.objects.get(name='groupAdmin') g.user_set.add(new_user) group_profile = GroupProfile.create(name=form_class.cleaned_data['group_name'], school=form_class.cleaned_data['school']) user_profile = UserProfile() user_profile.user = new_user user_profile.group = group_profile user_profile.save()
def save(self, user): group = GroupProfile() group.admin = user group.name = self.cleaned_data["name"] group.info = self.cleaned_data["info"] group.location_text = self.cleaned_data["location"] group.display_image = self.cleaned_data["display_image"] stats = GroupStats() stats.num_members = len(self.cleaned_data["members"]) stats.save() group.stats = stats group.save() group.members.add(*self.cleaned_data["members"]) group.save()
def create_group_profile1(sender, **kw): mygroup = kw["instance"] if kw["created"]: profile = GroupProfile() profile.group = mygroup profile.save()