UPDATE Operation
Now, lets learn how to perform update operation in django.
First of all, let us import Vaccine model
>>> from vaccine.models import Vaccine
Now, print the id of all vaccine objects using for loop.
>>> for object in Vaccine.objects.all():
... print(object.id)
...
1
Get the instance of any one of vaccine object.
>>> vaccine = Vaccine.objects.get(id=1)
Then, Get minimum_age of that vaccine instance
>>> vaccine.minimum_age
18
To update the minimum_age of vaccine object, assign any value to the minimum_age field of the vaccine instance and then use save() method.
>>> vaccine.minimum_age = 16
>>> vaccine.save()
>>> vaccine.minimum_age
16
In this way, we have learned how to perform simple update operation using django.