I don't know why it isn't showing on the templates when I think I implemented it right.
the template is :
<div class="row">...
For further actions, you may consider blocking this person and/or reporting abuse
Your
view
is not well structured. I see you repeating Volunteer.objects.all() twice. Also, your context is sending in arequest
obj, you are supposed to send the data that you fetched from your database i.eVolunteer.objects.all()
. Also what's theamlvideo = AMLVideo.objects.filter().order_by("-category", "-language", "-level")
for? You are not sending it to the templateOk so I removed the other Volunteer.objects.all() already. I would send those to the template. Just not on this model. How am I supposed to send the data form my database then?
I think you can restructure your view to look like this:
Then your template would look like this:
This solved the problem. Thank you!
Anytime!
Thanks for helping folks out and welcome to Dev.to!
My pleasure!
I think it is small loop issue
and context should be
Fixed it already with this plus the
<img src="{{ volunteer.image.url }}" class="img-responsive" alt="Image">
Now the image doesn't show
Your view is not sending any sensible data. It's sending the view function itself.
Try this:
I think that should display the data correctly. At that point, we can refactor a bit to make the code easier to read. Now you're using
volunteer
(in your template) as a variable name but in view, it contains all volunteers.So maybe renaming the
volunteer
intovolunteers
and then in your template code:into
and then replacing all
volunteer_name
withvolunteer
since you're passing in the entire model object, not just their name.Let me know if the first bit works!
After the refactoring, it would look like this
Template:
View:
(the model looks good as is)
Can you try this.
Data still didn't show. Do you think it's a bug on Django 2.2.4?
me too some template would show data but other wont even when i use the same even when i use the same way to display the data
you are setting context to home but home is set to anything. maybe you want
context = {'volunteer_name': volunteer_name, }
Hey thanks for replying. I tried this but is still not showing data on the front.
