[Answered ]-Python Django Queryset

2👍

I think you’re nearly there. You need to call the save method of the new product to save to the DB, and to retrieve the related client object, you should get not filter so you have the object itself and not a list of objects (or QuerySet):

detalle = Datos_empresa_DB.objects.get(pk=58)
#                                  ^^^
resp = Datos_equipo_DB(equipo='dell-labtop',marca='dell', modelo='432423',Foraneo_Datos_empresa_DB =detalle)
#                                          Save on model's related field <-^^^^^^^
resp.save()

Leave a comment