Last active
December 24, 2015 01:59
-
-
Save JuniorLima/6727913 to your computer and use it in GitHub Desktop.
Multiupload
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ImagemAdmin(AdminImageMixin, MultiUploadAdmin): | |
list_display = ('nome', 'imagemAdmin', 'projeto') | |
list_editable = ('projeto',) | |
def process_uploaded_file(self, uploaded, object, request): | |
# example: | |
projeto_id = request.POST.get('projeto_id', ['']) | |
title = request.POST.get('title', '') or uploaded.name | |
f = FotoProjeto(nome=title, img=uploaded, projeto_id=projeto_id) | |
f.save() | |
return { | |
'url': f.imagem(), | |
'thumbnail_url': f.imagem(), | |
'id': f.id, | |
'name': f.nome, | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Projeto(models.Model): | |
nome = models.CharField('Nome do projeto', max_length=50, unique=True) | |
conteudo = models.TextField('Descrição') | |
slugprojeto = models.SlugField(max_length=40, blank=True) | |
class Meta: | |
verbose_name = 'Projeto' | |
verbose_name_plural = 'Projetos' | |
def __unicode__(self): | |
return self.nome | |
class FotoProjeto(models.Model): | |
nome = models.CharField(max_length=50) | |
img = ImageField('Imagem do projeto', upload_to=rename_file_and_upload_to) | |
projeto = models.ForeignKey(Projeto, blank=True, null=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
['DoesNotExist', 'MultipleObjectsReturned'[, 'D'o_esNotE_xcilsats's, __''M, ul't_i_pdleeObljaetcttrs_R_e't, urned''_, _d'i_c_tc_l_a's, s__''_, _d'oc__d_e_l'a, tt'r____'e, q_'__'_, dict__'__'f, or'm_at__d_o'c, __''_, _g'e_t_aetqt_r_i'b, ut'__ef_o_r'mat__, ''_, _h'ash____'g, et'att_r_ibuitne_i_t_'_, ''_, _hasu'__module__'h, __''_, '__ini_tn_e_'_, _'u'__module__', , '_'__n_enwe____'', , '__re'd_u_cnee_w__'_, '', __'r_e_druecdeu_ceex____'', , '__'r_educe_e_xr__e'p, r__''__r, epr'____s'e, ta'__stetatttr__r'_, _''__, sizeof'____'s, iz'__str__eof'_, _'', __'subcla_sshook___s't, r_'___unicod'e_, _'', __'__wesakrefubc__'l, as's_hboase_manoagker_'_, '', _defau'l_t_manag_eru'n, ic'o_deferrdee_d_'', , '_'g_e_tw_eFaIkErLeDf__d_i's, pl'a_yb'a, se'_ge_t_nemxt_or_panarevgious_bery'_, FIELD'_d'ef, au'l_tg_emta_nnaegxetr_'o, r_p'revious_in__oderdefr'e, rr'e_dg'et, _p'k__gveatl_'F, IELD_dis'play_'g, et'__ugneitq_unee_xcth_eocrk_sp'r, evio'us_by__FIELmDe', ta'', _g'e_tpe_rfonremx_td_atoe_rch_epcrkes'v, io'_puesrf_oirmn__uonridqueer_c'h, eck's'_, ge't__spekt__pvk_avlal'', , '_get_'u_sntiaqtue'e, _c'hcleeacn'k, s'', clea'n__fmieeldts'a, ''dat, e_'e_rpreorrf_omrems_sdaagtee'_, checks'de'let, e'', _pe'rform_unique_checkfsu'l, l_'clean_se't, _p'ki_dv'a, l'', im'ag_esmt'a, te''i, ma'gceleamnA'd, mi'nc'l, ea'ni_mfige'l, ds''n, om'ed'a, te'_oebrjreocrt_sm'e, ss'apgke'', , 'p'rdeeplaertee_'d, at'afbualsle__cslaevae'n, '', pro'jeitod'', , 'pr'ojiemtoa_idg'e, m''s, ave''i, ma'gseavmeA_dbmasie'n, ''ser, ia'liimzga'b, le'_vanlouem'e, ''uni, qu'eo_bejrercotrs_'m, es'spakge'', , 'p'ruerpla'r, e_'dvaatlaibdaastee__suanvieq'u, e'']projeto' | |
, 'projeto_id', 'save', 'save_base', 'serializable_value', 'unique_error_message', 'url', 'validate_unique'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<td class="start"> | |
<!--<label>{%=locale.fileupload.titleLabel%}</label>--> | |
<input type="text" name="title" placeholder="{%=locale.fileupload.titleLabel%}"/> | |
{% endverbatim %} | |
<input type="text" style="display:none" name="projeto_id" value="{{ request.GET.projeto_id }}"/> | |
{% verbatim %} | |
{% if (!o.options.autoUpload) { %} | |
<button style="display: none";> | |
<i class="icon-ban-circle icon-white"></i> | |
<span>{%=locale.fileupload.start%}</span> | |
</button> | |
{% } %}</td> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment