本文整理汇总了Python中avatar.models.Avatar.user方法的典型用法代码示例。如果您正苦于以下问题:Python Avatar.user方法的具体用法?Python Avatar.user怎么用?Python Avatar.user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类avatar.models.Avatar
的用法示例。
在下文中一共展示了Avatar.user方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_photo
# 需要导入模块: from avatar.models import Avatar [as 别名]
# 或者: from avatar.models.Avatar import user [as 别名]
def create_photo(request):
error_message=''
user_name=''
form=FotosForm(request.POST, request.FILES)
if not form.is_valid():
context = RequestContext(request, {'form': form, 'mensagem_erro': error_message})
return render_to_response('cadastro/ppassos/new_photos.html',context)
try:
user_name=request.user.username
member=User.objects.get(pk=request.user.id)
if 'foto_perfil' in request.FILES:
photo_profile=Avatar()
photo_profile.avatar=request.FILES['foto_perfil']
photo_profile.user=member
photo_profile.primary=True
photo_profile.save()
if 'foto_divulgacao01' in request.FILES:
photo=Image()
photo.title=u'Foto de divulgação 01'
photo.image=request.FILES['foto_divulgacao01']
photo.member=member
photo.save()
if 'foto_divulgacao02' in request.FILES:
photo=Image()
photo.title=u'Foto de divulgação 02'
photo.image=request.FILES['foto_divulgacao02']
photo.member=member
photo.save()
except Exception,e:
error_message=u'<p style="color:#f00 !important;">Desculpe %s, mas houve um erro interno. Por favor entre em contato com [email protected]<br>%s</p>' % (user_name,e)
context = RequestContext(request, {'form': form, 'mensagem_erro': error_message})
return render_to_response('cadastro/ppassos/new_photos.html',context)