def save(self, commit=True): user = super(RegisterForm, self).save(commit=False) if commit: user.save() sdaeUser = SDAEUser(user=user, type=UserType.objects.get(name="Alumno")) sdaeUser.save() userStudent = Student(sdaeUser = sdaeUser) userStudent.save() return sdaeUser else: return None
def registerCompany(request): if request.method != "POST": cForm = CompanyForm() uForm = UserForm() else: cForm = CompanyForm(request.POST) uForm = UserForm(request.POST) if cForm.is_valid() and uForm.is_valid(): user = uForm.save(commit=False) user.is_active = False user.save() sdaeUser = SDAEUser(user=user, type=UserType.objects.get(name="Empresa")) sdaeUser.save() company = cForm.save(commit=False) company.sdaeUser = sdaeUser company.save() return HttpResponseRedirect("/login/") return render(request, "registration/register_company.html", {"cForm": cForm, "uForm": uForm})