1👍
✅
I believe that your filtering is incorrect. Instead of
invoiceitems = invoice_detailmain.serviceitems1.filter(pk=pk,user=request.user)
you should be using
invoiceitems = invoice_detailmain.serviceitems1.filter(user=request.user)
Although I’m baffled to why you have a primary key from both serviceinvoice
and serviceinvoiceitems
to your user model. It would probably be enough for you to specify
invoiceitems = invoice_detailmain.serviceitems1.all()
Source:stackexchange.com