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