Значения не печатаются в моей html таблице django 3 - PullRequest
1 голос
/ 08 мая 2020

Я хочу показать значения в таблице html, но условие if elif не работает или не сравнивается с no_of_days. no_of_days - поле таблицы базы данных.

    {% for item in all_reciept_vouchers %}
    <tr>
        {#  <td>{{  }}&nbsp;</td>#}
            <td>{{ item.job_no}}&nbsp;</td>
            <td>{{ item.invoice_no}}&nbsp;</td>
            <td>{{ item.party_name}}&nbsp;</td>
            <td>{{ item.module}}&nbsp;</td>
            <td>{{ item.invoice_amount}}</td>
            {% if item.no_of_days >= 0 and item.no_of_days <= 30 %}
                <td>{{ item.reciept_net_amount}}</td>
            {% elif item.no_of_days >= 31 and item.no_of_days <= 60 %}
                <td>{{ item.reciept_net_amount}} </td>
            {% elif item.no_of_days >= 61 and item.no_of_days <= 90 %}
                <td>{{ item.reciept_net_amount}} </td>
            {% elif item.no_of_days >= 91 and item.no_of_days <= 120 %}
                <td>{{ item.reciept_net_amount}} </td>
            {% endif %}

Класс модели

class RecieptVoucher (models.Model): voucher_no = models.CharField (max_length = 200) voucher_date = models.DateField (auto_now = False) , auto_now_add = False, null = True, blank = True) instrument_no = models.CharField (max_length = 200, null = True, blank = True) specific = models.CharField (max_length = 200, null = True, blank = True) bank_name = models.CharField (max_length = 200, null = True, blank = True) pay_to = models.CharField (max_length = 200, null = True, blank = True)

job_no = models.CharField(max_length=200, null=True, blank=True)
invoice_no = models.CharField(max_length=200, null=True, blank=True)
invoice_date = models.DateField(auto_now=False, auto_now_add=False, null=True, blank=True)
invoice_amount = models.CharField(max_length=200, null=True, blank=True)
party_name = models.ForeignKey(PartyMaster, on_delete=models.SET_NULL, null=True, related_name='rv_party_name', blank=True)
module = models.CharField(max_length=200, choices=Models, null=True, blank=True)

payable_amount = models.CharField(max_length=200, null=True, blank=True)
received_amount = models.CharField(max_length=200, null=True, blank=True)
rec_amount_date = models.DateField(auto_now=False, auto_now_add=False, null=True, blank=True)
no_of_days = models.CharField(max_length=200, null=True, blank=True)
tds = models.CharField(max_length=200, choices=TDS, null=True, blank=True)
tds_amount = models.CharField(max_length=200, null=True, blank=True)
reciept_net_amount = models.CharField(max_length=200, default="0", null=True, blank=True)
payment_net_amount = models.CharField(max_length=200, default="0", null=True, blank=True)
pending_amount = models.CharField(max_length=200, null=True, blank=True)

narration = models.CharField(max_length=200, null=True, blank=True)
bal_amt = models.CharField(max_length=200, default="0", null=True, blank=True)
balance_amount = models.CharField(max_length=200, null=True, blank=True)

def __str__(self):
    return self.voucher_no

Форма

class RecieptVoucherForm (forms.ModelForm): class Meta: model = RecieptVoucher fields = ' all ' widgets = {

        'voucher_no': forms.TextInput(attrs={'class': 'form-control'}),
        'voucher_date': forms.DateInput(attrs={'type': 'date', 'class': 'form-control'}, format="%Y-%m-%d"),
        'instrument_no': forms.TextInput(attrs={'class': 'form-control'}),
        'particular': forms.TextInput(attrs={'class': 'form-control'}),
        'bank_name': forms.TextInput(attrs={'class': 'form-control'}),

        'job_no': forms.TextInput(attrs={'class': 'form-control'}),
        'invoice_no': forms.TextInput(attrs={'class': 'form-control'}),
        'invoice_date': forms.DateInput(attrs={'type': 'date', 'class': 'form-control'}, format="%Y-%m-%d"),
        'invoice_amount': forms.TextInput(attrs={'class': 'form-control'}),
        'party_name': forms.Select(attrs={'class': 'form-control'}),
        'module': forms.Select(attrs={'class': 'form-control'}),

        'payable_amount': forms.TextInput(attrs={'class': 'form-control'}),
        'received_amount': forms.TextInput(attrs={'class': 'form-control'}),
        'rec_amount_date': forms.DateInput(attrs={'type': 'date', 'class': 'form-control'}, format="%Y-%m-%d"),
        'no_of_days': forms.TextInput(attrs={'class': 'form-control'}),
        'tds': forms.Select(attrs={'class': 'form-control'}),
        'tds_amount': forms.TextInput(attrs={'class': 'form-control'}),
        'reciept_net_amount': forms.TextInput(attrs={'class': 'form-control'}),
        'pending_amount': forms.TextInput(attrs={'class': 'form-control'}),

        'narration': forms.TextInput(attrs={'class': 'form-control'}),
        'bal_amt': forms.TextInput(attrs={'class': 'form-control'}),
        'balance_amount': forms.TextInput(attrs={'class': 'form-control'}),

    }
  1. Просмотры

    class RecieptVouchersReport (generi c .ListView): model = RecieptVoucher template_name = 'vouchers / reciept_vouchers / reciept_vouchers_report. html' context_object_name = 'all_reciept_vouchers'

    def get_queryset(self):
        return RecieptVoucher.objects.all()
    
...