Q:

How can i define user detail view in multiuser blog app?

I'm building a blog app with multi users and i'd like to have this ability that every logged user could click on every username (post author) and see details of this profile my current function gives me only details for current logged in user no mattew what user i click. i have similar CBV function working for post list view that shows me all the posts for each user and i've tried to do the same but it didn't worked.. Please help ;)
view
> @login_required
def profile_detail(request):
    context = {
        'profile': Profile.objects.all()
    }
    return render(request, 'users/user_detail.html', context)

model
class Profile(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
image = models.ImageField(default='default.jpg', upload_to='profile_pics')

def __str__(self):
    return f'{self.user.username} Profile'
def save(self, *args,**kwargs):
    super().save(*args,**kwargs)

    img = Image.open(self.image.path)

    if img.height >300 or img.width > 300:
        output_size = (300, 300)
        img.thumbnail(output_size)
        img.save(self.image.path)

url pattern
path('profile-detail/', user_views.profile_detail, name='user_detail'),

link
<a class="mr-2" href="{% url 'user_detail' %}">{{ post.author }}</a>

A:

Showing the profile of the logged in user
You obtain the Profile object for the logged in user with:
from django.shortcuts import get_object_or_404

@login_required
def profile_detail(request):
    context = {
        'profile': get_object_or_404(Profile, user=request.user)
    }
    return render(request, 'users/user_detail.html', context)
Showing the profile of the author
If you want to show the profile of the author, then you should pass it to the url. You thus can make a path that looks like:
urlpatterns = [
    # …,
    path('profile/<int:pk>', views.profile_detail, name='user_detail')
    # …,
]
in your template, you can render the url with:
<a class="mr-2" href="{% url 'user_detail' pk=post.author.pk %}">{{ post.author }}</a>
and in the view, you can then use the primary key of that user:
from django.shortcuts import get_object_or_404

@login_required
def profile_detail(request, pk):
    context = {
        'profile': get_object_or_404(Profile, pk=pk)
    }
    return render(request, 'users/user_detail.html', context)

