def form_valid(self, form): user_form = UserCreate(self.request.POST) if user_form.is_valid(): user = user_form.save() professor = form.save(commit=False) professor.user = user professor.user.is_professor = True professor.save() user.save() else: return self.form_invalid(form) return redirect(self.success_url)
def form_valid(self, form): user_form = UserCreate(self.request.POST) if user_form.is_valid(): user = user_form.save() student = form.save(commit=False) student.user = user student.user.is_student = True student.save() user.save() else: return self.form_invalid(form) return redirect(self.success_url)
def form_valid(self, form): user_form = UserCreate(self.request.POST) if user_form.is_valid(): user = user_form.save() admin = form.save(commit=False) admin.user = user admin.user.is_admin = True admin.save() user.save() else: return self.form_invalid(form) return redirect(self.success_url)
def form_invalid(self, form): user_form = UserCreate(self.request.POST) return self.render_to_response( self.get_context_data(form=form, user_form=user_form))