It is presently not possible to initialize new model instances from a given query set. To palliate this, let's introduce a new #build query set method that will allow to initialize a new model instance from the specified attributes.
For example:
Author.all.build(name: "John Doe")
Initializing new records through the #build method should result in the initialized model instance being scoped to the record from which originated the query set in case of reverse query sets (ie. query sets that are created when reverse relations are defined with the related option of many_to_one_field).
Description
It is presently not possible to initialize new model instances from a given query set. To palliate this, let's introduce a new
#build
query set method that will allow to initialize a new model instance from the specified attributes.For example:
Initializing new records through the
#build
method should result in the initialized model instance being scoped to the record from which originated the query set in case of reverse query sets (ie. query sets that are created when reverse relations are defined with therelated
option ofmany_to_one_field
).For example: