Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
176 views
in Technique[技术] by (71.8m points)

python 3.x - I am trying to display result table but subject1_title, subject1_credit_hour, subject1_grade and subject1_remarks are showing blank in frontend

I taking register# and name to search the database result, able to see the other field which is within the table, other fields are showing but not showing the above mention field data. I have already entered in the admin panel. Help Appreciated? I have created the models.py with the following value but unable to display it in the frontend.

subject1_title=models.CharField(max_length=40)
subject1_credit_hour=models.TextField()
subject1_grade_point=models.TextField()
subject1_grade=models.TextField()
subject1_remarks=models.CharField(max_length=20, null=True, blank=True)

my home.html page looks like this.

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
      th,
      td {
        border: 2px solid #666;
      }
      table.t1 {
        table-layout: fixed;
        width: 40%;
      }
    </style>
</head>

<h1><center>Search Your Result</center></h1>
<br>

<form method="POST" action=" " align="center">
    {% csrf_token %}
    {{ form }}
    <input type="submit" value="Submit"/>
    <br>
    <br>
    <br>
    {% for result_query in objects %}
    <table align="center">
    <tr>
       <th>S.N</th>
       <th>Course Code No.</th>
       <th>Course Title</th>
       <th>Cr.Hr.</th>
        <th>Grade Point</th>
        <th>Grade</th>
        <th>Remarks</th>
   </tr>
        <tr>
            <td>{{ result_query.subject1_code }}</td>
            <td>{{ result_query.subject1_title }}</td>
            <td>{{ result_query.subject1_credit_hour }}</td>
            <td>{{result.query.subject1_grade_point}}</td>
            <td>{{result.query.subject1_grade}}</td>
            <td>{{result.query.subject1_remarks}}</td>
        </tr>

        <tr>
            <td>{{ result_query.subject2_code }}</td>
            <td>{{ result_query.subject2_title }}</td>
            <td>{{ result_query.subject2_credit_hour }}</td>
            <td>{{result.query.subject2_grade_point}}</td>
            <td>{{result.query.subject2_grade}}</td>
            <td>{{result.query.subject2_remarks}}</td>
        </tr>

        <tr>
            <td>{{ result_query.subject3_code }}</td>
            <td>{{ result_query.subject3_title }}</td>
            <td>{{ result_query.subject3_credit_hour }}</td>
            <td>{{result.query.subject3_grade_point}}</td>
            <td>{{result.query.subject3_grade}}</td>
            <td>{{result.query.subject3_remarks}}</td>
        </tr>

        <tr>
            <td>{{ result_query.subject4_code }}</td>
            <td>{{ result_query.subject4_title }}</td>
            <td>{{ result_query.subject4_credit_hour }}</td>
            <td>{{result.query.subject4_grade_point}}</td>
            <td>{{result.query.subject4_grade}}</td>
            <td>{{result.query.subject4_remarks}}</td>
        </tr>

        <tr>
            <td>{{ result_query.subject5_code }}</td>
            <td>{{ result_query.subject5_title }}</td>
            <td>{{ result_query.subject5_credit_hour }}</td>
            <td>{{result.query.subject5_grade_point}}</td>
            <td>{{result.query.subject5_grade}}</td>
            <td>{{result.query.subject5_remarks}}</td>
        </tr>

        <tr>
            <td>{{ result_query.subject6_code }}</td>
            <td>{{ result_query.subject6_title }}</td>
            <td>{{ result_query.subject6_credit_hour }}</td>
            <td>{{result.query.subject6_grade_point}}</td>
            <td>{{result.query.subject6_grade}}</td>
            <td>{{result.query.subject6_remarks}}</td>
        </tr>


    </table>
{% endfor %}
</form>
</html>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...