From 9f2f281e853fdbe1094b2e63eb3acfc910f96518 Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Tue, 17 Nov 2015 15:08:06 -0200 Subject: [PATCH] Upload file with ModelForm in protocoloadm --- protocoloadm/models.py | 4 ++-- protocoloadm/views.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/protocoloadm/models.py b/protocoloadm/models.py index 7bfda6143..c43935efc 100644 --- a/protocoloadm/models.py +++ b/protocoloadm/models.py @@ -18,11 +18,11 @@ class TipoDocumentoAdministrativo(models.Model): def get_docadm_media_path(instance, subpath, filename): - return './docadm/%s/%s/%s' % (instance.numero, subpath, filename) + return './docadm/%s/%s/%s' % (instance, subpath, filename) def texto_upload_path(instance, filename): - return get_docadm_media_path(instance, 'docadm', filename) + return get_docadm_media_path(instance, 'DocAdm', filename) class DocumentoAdministrativo(models.Model): diff --git a/protocoloadm/views.py b/protocoloadm/views.py index b669ce60c..f15db09fa 100644 --- a/protocoloadm/views.py +++ b/protocoloadm/views.py @@ -810,7 +810,7 @@ class DocumentoAcessorioAdministrativoView(FormMixin, GenericView): doc_acessorio.data = form.cleaned_data['data'] doc_acessorio.autor = form.cleaned_data['autor'] doc_acessorio.assunto = form.cleaned_data['assunto'] - doc_acessorio.arquivo = form.cleaned_data['arquivo'] + doc_acessorio.arquivo = request.FILES['arquivo'] doc_acessorio.documento = DocumentoAdministrativo.objects.get( id=kwargs['pk']) doc_acessorio.save()