Search code examples
pythondjangodjango-modelsdjango-viewsdjango-users

How To Show User Profile To Everyone By Link! in Django


How To Show User Profile To Everyone By Link! in Django

I Want To Show User Profile To Everyone for-example if someone type this in browser domain.com/profile/1

Then Our First User Profile Want To Show

But it's showing blank

It's showing when user login but we need to show to everyone

Here is my detail.html

{% extends 'base.html' %}
{% block body_block %}

<h1 class="posttitle">{{user.username}}</h1>

{% endblock %}

Here is my Views.py

def profile_detail(request,pk):
    model = get_object_or_404(User, pk=pk)
    return render(request,'profile_detail_view.html')

If You Need More Files Like Model,Views,Url Something Let me down in comment i will update my question

Any Help Will Be Appreciated

Thanks!!


Solution

  • You are not passing the user instance to the detail.html .

    def profile_detail(request,pk):
        user = get_object_or_404(User, pk=pk)
        return render(request,'profile_detail_view.html',{'user':user})