How to write view in django to display friend_request which are sent by logged in user?

20 views
Skip to first unread message

Akshat Zala

unread,
Jan 10, 2020, 12:38:28 PM1/10/20
to Django users

my view to display friendlist:

def friend_list(request):
    context = {
        'results_from_user': 
                        Friend.objects.filter(from_user=request.user),
        'results_to_user': Friend.to_user
    }
    return render(request, 'friend/friend_list.html', context)

my template:

   {% for result in results_from_user %}
    {% if result.from_user == result.to_user %}
    <tr>{{pass}}</tr>
    {% endif %}
    <tr>
    <td>
        <img src="{{ result.from_user.profile.image.url }}" class="rounded-circle account-img"/>
    </td>
    <td>
        <ul>
            <li>
                <a href="{% url 'profile' result.from_user.id %}">{{result.from_user.first_name}} {{result.from_user.last_name }}</a>
            </li>
        </ul>
    </td>

It displays name of the logged in user with profile picture in a tabular format.


sagar ninave

unread,
Jan 10, 2020, 12:45:00 PM1/10/20
to django...@googlegroups.com
I did not get it please provide models.py

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/93780763-f241-44c7-ac71-83d898c842ef%40googlegroups.com.


--
Reply all
Reply to author
Forward
0 new messages