0
好的,這是userena的models.py。如果設置了mugshot,我可以在html中使用模板標籤進行檢查嗎?第一個if語句檢查是否上傳了照片。Django userena檢查是否設置了面部照片
def get_mugshot_url(self):
"""
Returns the image containing the mugshot for the user.
The mugshot can be a uploaded image or a Gravatar.
Gravatar functionality will only be used when
``USERENA_MUGSHOT_GRAVATAR`` is set to ``True``.
:return:
``None`` when Gravatar is not used and no default image is supplied
by ``USERENA_MUGSHOT_DEFAULT``.
"""
# First check for a mugshot and if any return that.
if self.mugshot:
return self.mugshot.url
# Use Gravatar if the user wants to.
if userena_settings.USERENA_MUGSHOT_GRAVATAR:
return get_gravatar(self.user.email,
userena_settings.USERENA_MUGSHOT_SIZE,
userena_settings.USERENA_MUGSHOT_DEFAULT)
# Gravatar not used, check for a default image.
else:
if userena_settings.USERENA_MUGSHOT_DEFAULT not in ['404', 'mm',
'identicon',
'monsterid',
'wavatar']:
return userena_settings.USERENA_MUGSHOT_DEFAULT
else:
return None
我曾嘗試過,但它沒有工作,因爲它需要評估到沒有我認爲它會返回false,所以我得到它通過使用一個圖片從互聯網工作,它返回到那個列表中都沒有。非常感謝:D –