Я новичок в django - python, поэтому мне нужны дополнительные детали. Все, что мне нужно, это предоставить ежемесячный отчет в формате PDF и годовой отчет, который также в форме PDF.
Из моего model.py
class Case(models.Model):
case_number = models.CharField(max_length=50, blank=True, null=True, unique=True)
reference_choice = (
('Personal', 'Personal'),
('Court', 'Court'),
)
reference = models.CharField(max_length=20, choices=reference_choice, null=True)
date_of_filing = models.DateField('Date of Filing (mm/dd/yyyy)*', blank=True, null=True)
official_receipt = models.CharField(max_length=50, blank=True, null=True,)
complainant = models.CharField(max_length=150)
respondent = models.CharField(max_length=150)
case_title = models.CharField(max_length=200)
На мои views.py
class GeneratePDF(View):
model = Case
def get(self, request, *args, **kwargs):
cases = Case.objects.filter.all()
context = {
'date': date,
'cases': cases,
}
pdf = render_to_pdf('pdf/monthly_report.html', context)
if pdf:
response = HttpResponse(pdf, content_type='application/pdf')
filename = 'monthly_report_%s.pdf' %('month')
content = 'inline; filename="%s"' % (filename)
response['Content-Disposition'] = content
return response
return HttpResponse('Not Found')
и на мой ежемесячный_отчет. html
<div class="container mt-4">
<table class="table-" style="width:1200px">
<thead class="thead-light">
<tr>
<th scope="col">Case Number</th>
<th scope="col">Complainant</th>
<th scope="col">Respondent</th>
<th scope="col">Case Title</th>
<th scope="col">Action Taken</th>
<th scope="col">Remarks</th>
</tr>
</thead>
<tbody>
{% for case in cases %}
<tr>
<td>{{ case.case_number }}</td>
<td>{{ case.complainant }}</td>
<td>{{ case.respondent }}</td>
<td>{{ case.case_title }}</td>
<td>{{ case.mediated| yesno }}</td>
<td>{{ case.remarks }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
В моем коде я получаю только все данные, но они не фильтруются.