[Answer]-Identifying & modifying single field in Django Model

1πŸ‘

βœ…

I really don’t understand your codes but because you mention disponible, I hope this is what you mean.

prestamo.fecha = timezone.now()
prestamo.devuelto = False

//Because Prestamo model has a foreignkey for Mate model. 
//The Mate model contains the disponible field which you want to access 
//     (to set it to False or unavailable)?
//This is how to access and update it.
prestamo.mate.disponible = False
prestamo.mate.save()

prestamo.save()
πŸ‘€catherine

Leave a comment