what is it?
single, definitive source of information about your data. it contains the essential fields and behaviors of the data you’re storing. generally, each model maps to a single database table
- each model is a python class that subclasses
django.db.models.Model. - each attribute of the model represents a database field.
- with all of this, django gives you an automatically-generated database-access API
refresh_from_db
to reload a model’s values from the database
when this method is called without arguments the following is done:
- all non-deferred fields of the model are updated to the values currently present in the database.
- any cached relations are cleared from the reloaded instance
obj = MyModel.objects.create(val=1)
obj.refresh_from_db()update_fields
if save() is passed a list of field names in keyword argument update_fields, only the fields named in that list will be updated