我试图在我们的Django网站中使用Userena,但我似乎不知道如何使用模板标签来显示面部照片。我尝试了以下方法,在图像标记中显示URL:
<img src="{{ owner_profile.get_mugshot_url }}">和
<img src="{{ profile.get_mugshot_url }}">有谁有什么见解吗?
谢谢!
发布于 2013-02-22 10:39:46
根据alican的回答,只需在您的模板中添加以下代码:
<img src="{{ user.get_profile.get_mugshot_url }}" />发布于 2012-03-23 18:25:43
使用以下代码在您的模板中显示Userena配置文件图像(Mugshot)。使用适当的用户名筛选所需的用户。
views.py
from django.shortcuts import get_object_or_404
from django.contrib.auth.models import User
def my_view(request):
profile = get_object_or_404(User, username__iexact=username).get_profile()
return render_to_response('template.html', locals(), context_instance=RequestContext(request))在这里,我将这个变量"profile“呈现给模板"template.html”。在您的模板中包含以下代码以显示面部照片图像。
template.html
<img src="{{ profile.get_mugshot_url }}" />这对我很管用。希望它也能为你工作。谢谢。
发布于 2012-08-18 21:07:27
试试这个:
{{ user.get_profile.get_mugshot_url }}https://stackoverflow.com/questions/9102968
复制相似问题