I have a django template containing 2 buttons. One is for show
and another is for print
.
I am getting a list of objects from model to print. And there is a status field boolean in this model.
The issue is after taking print, I want to update those objects by making their status field true
.
My code is here:
def msss_loan_marking_print_for_period(request, template_name=None):
site_prof = SiteProfile.objects.all()
fin_year = site_prof[0].current_financial_year()
context = {}
data1=[]
total=0
msss = request.session['cur_msss']
if request.method == 'POST':
form = SentToBankReportForm(request.POST)
if form.is_valid():
action = request.POST.get('action', None)
from_date = form.cleaned_data.get('start_date')
to_date = form.cleaned_data.get('end_date')
category = form.cleaned_data.get('type')
branch = form.cleaned_data.get('branch')
sent_status = form.cleaned_data.get('sent_status')
object = ShgGroupLoanMarking.objects.filter(sent_to_bank_status=False)
if action=='print':
context = {
'total': total,
'objects':objects,
'category': category,
'start_date': from_date,
'action': action,
'end_date': to_date,
}
template_name = 'report.html'
objects.update(status=True)
return pdf_utils.render_to_pdf_response(template_name, context, 'report.pdf')
I understood that we cant update the field lik that(objects.update(status=True)) in this problem. Is there any solution to make the model objects updated through djamgo template??