i'm having issues displaying parent.model.childmodel_set.all on my template

28 views
Skip to first unread message

stanley oguazu

unread,
May 3, 2018, 7:52:14 PM5/3/18
to Django users
//My template is only displaying the parent table, and not displaying child table

<!-- <div class="container">
       <div class="row">
           <div class="table-responsive">
               <table class="table table-striped table-bordered table-dark text-center">
                   <thead>
                       <tr>
                           <th scope="col">#</th>
                           <th scope="col">&nbsp;</th>
                           <th scope="col">User</th>
                           <th scope="col">&nbsp;</th>
                           <th scope="col">Weekly Goals</th>
                           <th scope="col">Daily Goals</th>
                           <th scope="col">Verify</th>
                           <th scope="col">Done</th>
                       </tr>
                       </thead>
                       
                       {% for user in my_users %}
                           
                       
                       <tbody>
                       <tr>
                           <th scope="row">{{ forloop.counter }}</th>
                           <td><a href="#"><i style="color:#FFF" class="far fa-plus-square"></i></a></td>
                           
                           <td>{{ user.fullname }}</td>
                           
                           <td><a href="#"><i style="color:#FFF" class="far fa-plus-square"></i></a></td>
                           {% for goal in my_users.scrumygoals_set.all %}
                           <td>{{ goal.goal_description }}</td>
                           <td></td>
                           <td></td>
                           <td></td>
                       </tr>
                   </tbody>
                       {% endfor %}
                   {% endfor %}
               </table>
           </div>
               
       </div>
   </div>
   
{% endblock %}

my view
Enter code here...
def index(request):

hello = 'Hello World'
my_users = ScrumyUser.objects.all()
return render(request, 'greyscrumy/index.html', {'my_users': my_users})


James Farris

unread,
May 3, 2018, 8:50:24 PM5/3/18
to django...@googlegroups.com
If you add {{ my_users }} to your template do you get any output? If not, you’re query set has no results. 

--
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 post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/02500f66-1283-49a9-b4c3-4fe723a497d0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

stanley oguazu

unread,
May 4, 2018, 12:45:34 AM5/4/18
to Django users
Yes all the data in ScrumyUser table displays
Reply all
Reply to author
Forward
0 new messages