【问题标题】:I am trying to disply the search value and already filled the details but i can't see the input value of last 3 column ? Help Appricated我正在尝试显示搜索值并已填写详细信息,但我看不到最后 3 列的输入值?帮助赞赏
【发布时间】:2021-01-13 04:34:50
【问题描述】:

我已输入数据,然后单击搜索按钮,我可以看到另一列和行显示数据,但当我单击搜索按钮时,我看不到最后 3 列和行数据。 附上截图供参考。 screenshot

这是我的moodle.py

from django.db import models
from django.utils.encoding import smart_text
from multiselectfield import MultiSelectField

# Create your models here.




class ResultQuery(models.Model):
    os_choice = (
        ('Select an Institution', 'Select an Institution'),
        ('School of Management', 'School of Management'),
    )
    operating_system = models.CharField(max_length=30, blank=True,  null=True, choices=os_choice)
    os_choice2 = (
        ('Select a level', 'Select a level'),
        ('Bachelor', 'Bachelor'),
        ('Master', 'Master'),

    )

    level = models.CharField(max_length=30, blank=True, null=True, choices=os_choice2)

    os_choice3 = (
        ('Select a Program', 'Select a Program'),
        ('MBA', 'MBA'),
        ('BBA', 'BBA'),
        ('BHM', 'BHM'),

    )
    program = models.CharField(max_length=30, blank=True, null=True, choices=os_choice3)

    os_choice4 = (
        ('Select a Semester', 'Select a Semester'),
        ('1st', '1st'),
        ('2nd', '2nd'),
        ('3rd', '3rd'),
        ('4th', '4th'),
        ('5th', '5th'),
        ('6th', '6th'),
        ('7th', '7th'),
        ('8th', '8th'),
    )

    semester = models.CharField(max_length=20, blank=True, null=True, choices=os_choice4)

    exam_year = models.IntegerField()

    institute = models.CharField(max_length=4)
    reg_no = models.CharField(max_length=50)
    symbol_num = models.IntegerField()


    student_name = models.CharField(max_length=50)
    dob = models.DateField()

    sgpa = models.TextField()
    result = models.CharField(max_length=40)
    name = models.CharField(max_length=30)
    sn = models.IntegerField(max_length=222, blank=True, null=True)
    subject1_code=models.CharField(max_length=40)
    subject1_title=models.CharField(max_length=40)
    subject1_credit_hour=models.TextField()
    subject1_grade_point=models.IntegerField(max_length=212, blank=True, null=True)
    subject1_grade=models.TextField()
    subject1_remarks=models.CharField(max_length=20, null=True, blank=True)

    subject2_code = models.CharField(max_length=40)
    subject2_title = models.CharField(max_length=40)
    subject2_credit_hour = models.TextField()
    subject2_grade_point = models.TextField()
    subject2_grade = models.TextField()
    subject2_remarks = models.CharField(max_length=20, null=True, blank=True)

    subject3_code = models.CharField(max_length=40)
    subject3_title = models.CharField(max_length=40)
    subject3_credit_hour = models.TextField()
    subject3_grade_point = models.TextField()
    subject3_grade = models.TextField()
    subject3_remarks = models.CharField(max_length=20, null=True, blank=True)

    subject4_code = models.CharField(max_length=40)
    subject4_title = models.CharField(max_length=40)
    subject4_credit_hour = models.TextField()
    subject4_grade_point = models.TextField()
    subject4_grade = models.TextField()
    subject4_remarks = models.CharField(max_length=20, null=True, blank=True)

    subject5_code = models.CharField(max_length=40)
    subject5_title = models.CharField(max_length=40)
    subject5_credit_hour = models.TextField()
    subject5_grade_point = models.TextField()
    subject5_grade = models.TextField()
    subject5_remarks = models.CharField(max_length=20, null=True, blank=True)

    subject6_code = models.CharField(max_length=40)
    subject6_title = models.CharField(max_length=40)
    subject6_credit_hour = models.TextField()
    subject6_grade_point = models.TextField()
    subject6_grade = models.TextField()
    subject6_remarks = models.CharField(max_length=20, null=True, blank=True)

    def __str__(self):
       return smart_text(self.name)

这是我的 index.html

{% load static %}
{% load crispy_forms_tags %}
{% block content %}
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>online</title>

    <meta name="description" content="Source code generated using layoutit.com">
    <meta name="author" content="LayoutIt!">

    <link href="{% static 'css/bootstrap.min.css' %}" rel="stylesheet">
    <link href="{% static 'css/style.css' %}" rel="stylesheet">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">


<style>

    select, input {max-width: 16em};



</style>
    

  </head>
  <body>

    <div class="container-fluid">
        <div class="row" id="top">
            <div class="col-md-12">
            </div>
        </div>
    <div class="row">
        <div class="col-md-12">
            <div class="row">
                <div class="col-md-4" id="h4">
                </div>
                <div class="col-md-4" id="logo">
                    <img src="{% static 'img/logo.png' %}" alt="" srcset="">
                    <br>
                    <h1 class="a">Saj University School of Management</h1>
                </div>
                <div class="col-md-4" id="h4">
                    <h4>Online Result Form V1.</h4>
                </div>
            </div>
            <div class="row" id="top">
                <div class="col-md-12">
                </div>
            </div>
            
            <br>
            <div class="row">
                <div class="col-md-4">


                    <style>
    h3{
        color: black;
        padding-right: 84px;

        }
    body{
        background-color: white;
        }
      th,
      td {
        border: 2px solid #666;
        color: black;
        padding-top: 14px;
        padding-right: 110px;

      }
      table.t1 {
        table-layout: fixed;
        width: 40%;
        color: black;
      }

    </style>

      <style>
  input[type=submit], input[type=reset] {
  background-color: #31307a;
  width: 400px;
  border: none;
  color: white;
  padding: 16px 32px;
  text-decoration: none;
  margin: 4px 2px;
  cursor: pointer;
  margin: 0px, 10px, 2000px;
  position: relative;
  top: -10px;
  left: -175px;

}
</style>



</head>
{% for value, text in form.providers.field.choices %}
  <div class="ui slider checkbox">
    <input id="id_providers_{{ forloop.counter0 }}" name="{{ form.providers.name }}" type="checkbox" value="{{ value }}"{% if value in checked_providers %} checked="checked"{% endif %}>
    <label>{{ text }}</label>
  </div>
{% endfor %}
<br>

<form method="POST" action="" align="center">
    {% csrf_token %}
    {{form|crispy}}
    <br>
    <input type="submit" id="done" value="Submit"/>
    <br>
    <br>

</form>
                </div>

<div class="col-md-8">












{% for result_query in objects %}
    <table align="center">
        <h3>Grade Sheet</h3>
    <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.sn }}</td>
            <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.sn }}</td>
            <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.sn }}</td>
            <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.sn }}</td>
            <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.sn }}</td>
            <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.sn }}</td>
            <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 %}






                    </div>
                </div>
                <div class="col-md-12" id="h6">
                    <h3><b>Announcement</b></h3>
                    <marquee behavior="scroll" direction="left" id="mymarquee" scrollamount="10">
                        <h4>Brothers and Sisters, the time has come for each and every one of you to decide whether you are going to be the problem or whether you are going to be the solution! (That's right!)
                            You must choose Brothers, you must choose!It takes five seconds, five seconds of decision, five seconds to realize your purpose here on the planet!
                            It takes five seconds to realize that it's time to move, it's time to get down with it! Brother</h4>
                        </marquee>
                        <input type="button" value="&#9208;" onClick="document.getElementById('mymarquee').stop();">
                        <input type="button" value="&#9654;&#65039;" onClick="document.getElementById('mymarquee').start();">


    
                </div>
            </div>
        </div>
    </div>


    <div class="row">
        <div class="col-md-12">
            <div class="row">
                <div class="col-md-4" id="h4">
                </div>
            </div>
            <div class="row" id="top1">
                <div class="col-md-12">
                </div>
            </div>


    <div class="row">
        <div class="col-md-12" id="footer">
                <p>© 2021 Sajtheme, Nepal | All Rights Reserved.</p>
        </div>
    </div>
    <div class="row">
        <div class="col-md-12">
            <div class="row">
                <div class="col-md-4" id="h4">
                </div>
            </div>
            <div class="row" id="top13">
                <div class="col-md-12">
                </div>
            </div>

    
</div>

    <script src="{% static 'js/jquery.min.js' %}"></script>
    <script src="{% static 'js/bootstrap.min.js' %}"></script>
    <script src="{% static 'js/scripts.js' %}"></script>
  </body>
</html>
{% endblock content %}

这是我的意见.py

from django.shortcuts import render

# Create your views here.
from django.shortcuts import render
from .forms import ResultForm
from .models import ResultQuery



def home(request):
    form=ResultForm(request.POST or None)
    template_name = "index.html"
    context = {"form": form}
    if form.is_valid():
        objects = ResultQuery.objects.filter(exam_year=form.cleaned_data['Exam_Year'], operating_system=form.cleaned_data['OS'], level=form.cleaned_data['cat'], program=form.cleaned_data['cho'], semester=form.cleaned_data['sem'], symbol_num=form.cleaned_data['sym'], dob=form.cleaned_data['db'])
        context['objects'] = objects

    return render(request, template_name, context)

这是我的 forms.py

from django import forms
from search.models import ResultQuery
from django.forms import MultipleChoiceField, ChoiceField, Form
class ResultForm(forms.Form):
      OS = forms.ChoiceField(choices=ResultQuery.os_choice)
      cat = forms.ChoiceField(choices=ResultQuery.os_choice2)
      cho = forms.ChoiceField(choices=ResultQuery.os_choice3)
      sem = forms.ChoiceField(choices=ResultQuery.os_choice4)
      Exam_Year = forms.CharField(widget=forms.TextInput(attrs={'type':'dob',
                                                             'class': 'form-control',
                                                             'placeholder': 'Exam Year'}))
      sym = forms.CharField(widget=forms.TextInput(attrs={'type':'dob',
                                                             'class': 'form-control',
                                                             'placeholder': 'Symbol Number'}))
      db = forms.DateField(widget=forms.TextInput(attrs={'type':'dob',
                                                             'class': 'form-control',
                                                             'placeholder': 'YYYY-MM-DD'}))

【问题讨论】:

    标签: python-3.x django django-models django-views django-forms


    【解决方案1】:

    您可能没有保存这些列的值,因为您为它们设置了空白和 null True。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-05-23
      • 2012-05-29
      • 1970-01-01
      • 1970-01-01
      • 2022-07-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多