[Answered ]-Construct new django model object without loading all related models into memory

2👍

This should work fine using the usual model class constructor and the _id name rather than an __id chained relationship as in your example code for the foreign key id:

new_child_entity = ObjectChildEntity(myobject_id=123, some_data='foo', related_stuff_id=456)
new_child_entity.save()

Or, if you’ve overridden the db_column field in the model field declaration, that name instead of myobject_id.

Leave a comment