How to use the Django Usurena “mugshot” template variable

前端 未结 4 1572
名媛妹妹
名媛妹妹 2021-01-21 21:44

I\'m trying to use Userena in our Django website, but I can\'t seem to figure out how to use the template tag to display the mugshot. I have tried the following to spit out the

4条回答
  •  深忆病人
    2021-01-21 22:35

    Use the following code to display Userena profile image(mugshot) in your template. Use appropriate username to filter the required user.

    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))
    

    Here I have rendered this variable "profile" to the template "template.html". Include following code in your template to display mugshot image.

    template.html

        
    

    It worked for me. Hope it will work for you too. Thanks.

提交回复
热议问题