Add upsert, save_related, allow dict in fields and exclude_fields, optimisation and cleanup etc.
Pre-release
Pre-release
- Added save status -> you can check if model is saved with
ModelInstance.savedproperty- Model is saved after
save/update/load/upsertmethod on model - Model is saved after
create/get/first/all/get_or_create/update_or_createmethod - Model is saved when passed to
bulk_updateandbulk_create - Model is saved after adding/removing
ManyToManyrelated objects (through model instance auto saved/deleted) - Model is not saved after change of any own field (including pk as
Model.pkalias) - Model is not saved after adding/removing
ForeignKeyrelated object (fk column not saved) - Model is not saved after instantation with
__init__(w/oQuerySet.createor before callingsave)
- Model is saved after
- Added
Model.upsert(**kwargs)that performssave()if pk not set otherwiseupdate(**kwargs) - Added
Model.save_related(follow=False)that iterates all related objects in all relations and checks if they are saved. If not it callsupsert()on each of them. - Breaking: added raising exceptions if
add-ing/remove-ing not saved (pk is None) models toManyToManyrelation - Allow passing dictionaries and sets to fields and exclude_fields
- Auto translate str and lists to dicts for fields and exclude_fields
- Breaking: passing nested models to fields and exclude_fields is now by related ForeignKey name and not by target model name
- Performance optimizations - in modelproxy, newbasemodel - > less queries, some properties are cached on models
- Cleanup of unused relations code
- Optional performance dependency orjson added (strongly recommended)
- Updated docs