'Cannot assign "<Invoive: Project>": "Invoive.user" must be a "InvoiveCompany" instance
New in Python code stuffs need a help,
Invoices = Parent,
Items = Child,
I need to add This child items in parent, If i directly save this with the code below it creates item for all, Not the specific parent ID. How can i just save this form to a specific ID.
Tried
ItemsForm(request.POST, instance=invoices)
but that didnt work.
def add(request, pk):
datas = Items.objects.all()
invoices = Invoive.objects.get(id=pk)
items = invoices.Items.all()
if request.method == 'POST':
itemform = ItemsForm(
request.POST)
if itemform.is_valid():
itemform.save()
return redirect(request.META.get('HTTP_REFERER'))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|