Changelog#
0.2#
0.2.0#
Breaking changes#
Dropped support for Django 4.2 (end of life). Supported: Django 5.2, 6.0 and 6.1.
A config in which two models share a class name now raises
ImproperlyConfiguredbefore the copy starts. In 0.1 such a copy mixed the models in the result maps and wrote wrong references. Passmap_keys=MapKeys.LABELto copy it.TAKE_FROM_ORIGINandTAKE_FROM_INPUTon a foreign key now store the key column inCopyIntent.copy_data("project_id": 1instead of"project": <Project>). This matters only if a postcopy function readscopy_data.Callback protocols (
IgnoreFunc,SetToFilterFunc,DataPreparationFunc,PostcopyFunc) take keyword-only arguments, which is how the engine always called them. Type checkers now accept callbacks written asdef f(**kwargs).Removed
Copyist.get_copyist_for_request. It referenced attributes that did not exist and failed on every call.
Added#
Public API in the package root:
from django_copyist import ModelCopyConfig, run_copy, .... Names indjango_copyist.__all__follow semantic versioning.run_copy(): build the request and run the copy in one call.CopyResult.copies_of(Model): origin to copy primary keys for one model.MapKeysandmap_keysonCopyistConfigandrun_copy(). The default,MapKeys.MODEL_NAME, keeps the 0.1 keys ("Company").MapKeys.LABELkeys the maps by model label ("demo.Company"), so models with the same class name in different apps can be copied together.TakeFromInput(key)shortcut.check_config(): static checks of a config against model metadata, with stable issue codes (copyist.E001tocopyist.E012,copyist.W001tocopyist.W005).manage.py copyist_scaffold app.Model: prints a starting config for a model tree. Needs"django_copyist"inINSTALLED_APPS. Also available asdjango_copyist.scaffold.scaffold_config().usingandbatch_sizeoptions onCopyRequestandrun_copy().TAKE_FROM_INPUTon a foreign key accepts a primary key value as well as a model instance.Clear
NotSupportedErrorwhen the database does not return primary keys frombulk_create(MySQL, Oracle).py.typedmarker: type checkers now use the package annotations. The package passesmypy --strictwith django-stubs, and CI checks it together with sample user code (example/typing_examples.py).Support for Django 6.0 and 6.1 and Python 3.15.
Benchmark against django-clone and a naive loop (
benchmarks/, results in the docs).llms.txtandllms-full.txtin the documentation for AI coding assistants.
Fixed#
Many-to-many fields with
TAKE_FROM_ORIGINorSET_TO_FILTERfailed withIntegrityErrorwhen more than one row was copied.TAKE_FROM_ORIGINon a foreign key ran one query per row to load the related object. It now copies the key column.Models whose primary key is not named
idfailed withFieldErrorinSET_TO_FILTERand ignore conditions.compound_copy_actionswith several nullableUpdateToCopiedforeign keys used the wrong model’s ids and skipped rows.0,Falseand""ininput_datawere rejected as missing filter values.Models without an
objectsmanager failed. The engine uses the default manager now.Children of rows skipped by an unmatched
SET_TO_FILTERvalue failed withKeyErrorunderconfirm_write=True. They are skipped with their parent now.Copies with more rows per level than the database parameter limit failed on SQLite with “too many SQL variables”. Long
INlookups are split into chunks.
0.1#
0.1.3#
Improved docs
0.1.1#
Specified python >=3.11
0.1.0#
Initial release