def institutions_new(request): if request.method == 'POST': form = InstitutionForm(request.POST, request.FILES) if form.is_valid(): save = form.save() message = 'Institucion guardado correctamente!' messages.add_message(request, messages.SUCCESS, message) return HttpResponseRedirect(reverse(institutions_index)) else: form = InstitutionForm return render(request, 'institutions/new.html', { 'form': form, })
def institutions_edit(request, id): institution_id = int(id) institution = Company.objects.get(id=institution_id) if request.method == 'POST': form = InstitutionForm(request.POST, request.FILES, instance=institution) if form.is_valid(): save = form.save() message = 'Institucion actualizado correctamente!' messages.add_message(request, messages.SUCCESS, message) return HttpResponseRedirect(reverse(institutions_index)) else: form = InstitutionForm(instance=institution) return render(request, 'institutions/edit.html', { 'form': form, })