def add(request): school_form = SchoolForm( data=request.POST or None ) if school_form.is_valid(): school_form.save(auth.get_user(request)) messages.success(request, u"Material salvo com sucesso.") return redirect('school_list') template_context = { 'school_form': school_form, } return render( request=request, template_name='school/add.html', dictionary=template_context )
def edit(request, pk): school = get_object_or_404( klass=School, pk=pk ) school_form = SchoolForm( data=request.POST or None, instance=school ) if school_form.is_valid(): school_form.save(auth.get_user(request)) messages.success(request, u"Material editado com sucesso.") return redirect('school_list') template_context = { 'school': school, 'school_form': school_form, } return render( request=request, template_name='school/edit.html', dictionary=template_context )