Having problem dealing with data in template

hello everyone,
I am trying to make a template that will display a course in my website,
basically the data structure looks like this , each course have multi sections, and every section has multi lectures, I want to make a div that contains a list of all the lectures in a specific course.
the structure should look like :

  <div>
        
            {% for temp_section in course_sections%}
                {% include "main_website/includes/course_section.html" %}
            {% endfor %}
            
        
        </div>

and course section should look like

<div>
    <div class="section_title_div">
        <h2 class="section_title">{{temp_section.name}}</h2>
    </div>
        {% for lecture in lectures %}
            <div class = "lecture_section">
                <span class="lecture_status">status check</span>
                <div >
                    
                    <span class="lecture_type">lecture type</span>
                    <h2>השם של השיעור וכו וכו</h2>
                    {% if True %} <!-- if no need to buy the course-->
                        <button class="start_now_button"> start now</button>
                    
                    {% else %}
                        <button> buy the course now</button>
                    {% endif %}
                    
                </div>
            </div>
    {% endfor %}

</div>

the problem is I only pass a course to the template, so when I try to accesses the course.sections i get a db pointer and not the actual data. ofc you cant querry in side a tamplate so i cant do course.sections.all().
this is the view function

def course_page(request,id):
    temp_course = course.objects.get(id=id)
    return render(request,"main_website/course_page.html",{
        "the_course":temp_course,
        "user":request.user
        
    })

is there any way to get all the infromation just from passing the course or i need to pass everything separately like so:


def course_page(request,id):
    temp_course = course.objects.get(id=id)
    return render(request,"main_website/course_page.html",{
        "the_course":temp_course,
        "sections":temp_course.sections.all(),
        "lectures": [x.lectures.all() for x in temp_course.sections.all()],
        "user":request.user
        
    })

and if there is no other way, is there an easy way to organize the data, for example have an array for each section with him on lectures or do i need to develop it mannuly?

thanks alot

Correct, but you can reference it within your template as course.sections.all

The Django template engine attempts to interpret variables in different ways. This includes checking to see if the variable is a callable, and if so, calls it.

thank you so much! it works.