def get_picture(self):
no_picture = 'http://localhost:8000/static/img/user.png'
try:
filename = django_settings.MEDIA_ROOT+'/webuser_pictures/'+self.user.username+'.jpg'
picture_url = django_settings.MEDIA_URL+'webuser_pictures/'+self.user.username+'.jpg'
if os.path.isfile(filename):
return picture_url
else:
# gravatar_url = u'http://www.gravatar.com/avatar/{0}?{1}'.format(
# hashlib.md5(self.user.email.lower()).hexdigest(),
# urllib.urlencode({'d':no_picture, 's':'256'})
# )
gravatar_url='http://localhost:8000/static/img/user1.png'
return gravatar_url
except Exception, e:
return no_picture
评论列表
文章目录