


concrete_fields ): values = list ( values ) values. In addition to creating the new model, the from_db() method must set theĪdding and db flags in the new instance’s _state attribute.īelow is an example showing how to record the initial values of fields thatįrom django.db.models import DEFERRED def from_db ( cls, db, field_names, values ): # Default implementation of from_db() (subject to change and could # be replaced with super()). In that case, assign a value of django.db.models.DEFERRED If any fields are deferred, they won’t appear inįield_names. That is, the instance can be created byĬls(*values). If all of the model’sįields are present, then values are guaranteed to be in the order Theįield_names are in the same order as the values. Values contains the loaded values for each field in field_names. Is loaded from, field_names contains the names of all loaded fields, and The db argument contains the database alias for the database the model The from_db() method can be used to customize model instance creation Customizing model loading ¶ classmethod Model.
