Reputation: 2686
I have a view that is supposed to be gathering all the objects for a currently authenticated user from three tables TSFH
, TSUH
, and TSJH
and gather all those objects for the currently logged in user, if that user exists.
However, my view
logic is currently falling into the else
statement it appears.
Can someone help me debug why this might be happening?
My tables have data for the currently logged in user, so I am not sure why this is happening.
Views.py
def SHO(request):
TSUH = TSUH.objects.filter(FKToUser_id=request.user).all()
TSFH = TSFH.objects.filter(FKToUser_id=request.user).all()
TSJH = TSJH.objects.filter(FKToUser_id=request.user).all()
return render(request, 'page.html', {
'TSUH':HasTSUH,
'TSFH':HasTSFH,
'TSJH':HasTSJH
})
templates/page.html
{% autoescape on %}
{% if HasTSUH %}
{% for t in HasTSUH %}
<li>{{ t.begin }}<span></li>
{% endfor %}
{% elif HasTSFH %}
{{ HasTSFH }}
{% elif TSJH %}
{{ TSJH }}
{% else %}
It appears you haven't done anything yet.
{% endif %}
However it keeps displaying:
It appears you haven't done anything yet.
what am i doing wrong here? thanks
Upvotes: 0
Views: 17
Reputation: 599490
The names in the template are the keys of the context dict. You've used TSUH
, TSFH
, and TSJH
, without the Has
.
Upvotes: 1