Web page that displays a doctype's data not working

Hello, I’m very new to frappe so I was working on our list and we are also using a custom module, so back to the topic I was working on our list that should display a data however the outcome was different it only displayed a header or a table header a say but it didn’t fetch the data from the specific doctype we were using

here are the codes

Hi there,

It’s a bit hard to read in screenshots like this, but you appear to define the get_context method twice? The second is overwriting the first, and as a consequence there’s no variable called book_list for your jinka template to parse.

hmmm I see so how should I do it? and sorry for the picture do and thank you for helping me since I will removing that duplicated get_context method

Just erase the first method and keep the second one. I believe you need to return context too, but I can’t remember off hand and I’m not in a position to test right now. Make sure the variable you’re exporting matches the name you’re using in your jinka template.

ok I already did what you said but the same outcome

What have you done to troubleshoot?

remove the first method added return context and edited the variables lemme send you a code picture

here are the codes

book_list.html


<h2> Books List </h2>

{% if booker_list %}

  <head>
    <style>
      table {
        font-family: arial, sans-serif;
        border-collapse: collapse;
        width: 100%;
      }

      td, th {
        border: 1px solid #dddddd;
        text-align: left;
        padding: 8px;
      }

      tr:nth-child(even) {
        background-color: #dddddd;
      }
    </style>
  </head>

  <table>
      <tr>
        <th>Title</th>
        <th>Author</th>
        <th>Subject</th>
      </tr>
    {% for books in book_list %}
      <tr>
        <td>{{ books.get("title", "")  }} </td>
        <td>{{ books.get("lbks_author", "") }}</td>
        <td>{{ books.get("lbks_subject", "") }}</td>
    {% endfor %}
  </tr>
  </table>

{% else %}

  <p style="font-size:36px; ">No orders!</p>

{% endif %}

book_list.py

import frappe


def get_context(context):
    context.booker_list = frappe.get_list("Library Books", fields=["title", "lbks_author", "lbks_subject"])
                          ##end of function

    return context

just correct the codes so we can finish this fast lol

Sorry mate, but I’m not your employee. If you’re looking for someone to do the work for you, there are many places where you can hire an erpnext freelancer. Good luck.

my bad but yeah what should I change do? didn’t mean it to be a bossy approach do trying to approach it in a joking way

appreciate your help I’ll just have to pass this to our school without the custom page

The documentation is an important piece here, but more than anything I would suggest brushing up on your Jinja. You’ve got a line:

{% for books in book_list %}

…but nowhere do you define a variable called book_list. You did in your original script, but defined the same method twice.