Click here to Skip to main content
15,886,806 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am creating a web app and I want this to display other user's profile through the user's post.

I mean when a user click on other user's profile for see the other user's information then it will show the other user's profile. I've tried everything but it is showing the name of the current user information after click on the post.

Please Help me in this. Thank you very Much. I will really appreciate your Help.

Please help me in this, I don't know where is the problem

What I have tried:

Here is my Code:-

views.py
Python
def post_profile(request,username):
    poste = Profile.objects.get(user=request.user)
    context = {'poste':poste}
    return render(request, 'mains/post_profile.html', context)

models.py
Python
class Profile(models.Model):
    user = models.OneToOneField(User, on_delete=models.CASCADE,default='',unique=True)
    full_name = models.CharField(max_length=100,default='')
    date_added = models.DateTimeField(auto_now_add=True)

post_profile.html - ( This is the template of, which will show the other user's profile . )
HTML
{% extends "mains/base.html" %}

{% block content %}

{% for topic in poste %}
    <a>{{ topic.full_name }}</a><br>
{% empty %}
    <li>No informtion.</li>
{% endfor %}

</ul>

{% endblock content %}
Posted
Updated 25-Nov-20 22:47pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900