diff options
Diffstat (limited to 'python-django-clone.spec')
| -rw-r--r-- | python-django-clone.spec | 850 |
1 files changed, 850 insertions, 0 deletions
diff --git a/python-django-clone.spec b/python-django-clone.spec new file mode 100644 index 0000000..de72c27 --- /dev/null +++ b/python-django-clone.spec @@ -0,0 +1,850 @@ +%global _empty_manifest_terminate_build 0 +Name: python-django-clone +Version: 5.3.1 +Release: 1 +Summary: Create a clone of a django model instance. +License: MIT/Apache-2.0 +URL: https://github.com/tj-django/django-clone.git +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/c4/f0/d5e399c401dfaf7a46451132ed393892929a884909859ae5bdb68620c873/django-clone-5.3.1.tar.gz +BuildArch: noarch + +Requires: python3-django +Requires: python3-conditional +Requires: python3-six +Requires: python3-bump2version +Requires: python3-readme-renderer[md] +Requires: python3-git-changelog +Requires: python3-pip-tools +Requires: python3-check-manifest +Requires: python3-django +Requires: python3-conditional +Requires: python3-six +Requires: python3-tox +Requires: python3-tox-gh-actions +Requires: python3-pluggy +Requires: python3-mock +Requires: python3-unittest-xml-reporting +Requires: python3-codacy-coverage +Requires: python3-django-migration-fixer +Requires: python3-bump2version +Requires: python3-readme-renderer[md] +Requires: python3-git-changelog +Requires: python3-tox +Requires: python3-tox-gh-actions +Requires: python3-pluggy +Requires: python3-mock +Requires: python3-unittest-xml-reporting +Requires: python3-codacy-coverage +Requires: python3-django-migration-fixer + +%description +<p align="center"> + <img width="466" alt="4FC889E9-FF59-4E44-9EB6-2AF7DC034C74" src="https://user-images.githubusercontent.com/17484350/215616634-17439a58-7bd8-4e9c-989f-e6bef7c73e48.png"> +</p> + +| Python | Django | Downloads | Code Style | +|:---------:|:-------:|:-----------:|:--------------:| +| [](https://pypi.org/project/django-clone) | [](https://docs.djangoproject.com/en/3.2/releases/) | [](https://pepy.tech/project/django-clone) | [](https://github.com/psf/black) | + +| PyPI | Test | Vulnerabilities | Coverage | Code Quality | Pre-Commit | +|:---------------:|:----:|:---------------:|:--------:|:-------------:|:-------------:| +| [](https://badge.fury.io/py/django-clone) | [](https://github.com/tj-django/django-clone/actions?query=workflow%3ATest) | [](https://snyk.io/test/github/tj-django/django-clone?targetFile=requirements.txt) | [](https://www.codacy.com/gh/tj-django/django-clone?utm_source=github.com\&utm_medium=referral\&utm_content=tj-django/django-clone\&utm_campaign=Badge_Coverage) <br/> [](https://codecov.io/gh/tj-django/django-clone)| [](https://www.codacy.com/gh/tj-django/django-clone?utm_source=github.com\&utm_medium=referral\&utm_content=tj-django/django-clone\&utm_campaign=Badge_Grade) | [](https://results.pre-commit.ci/latest/github/tj-django/django-clone/main) | + +## django-clone + +Create copies of a model instance with explicit control on how the instance should be duplicated (limiting fields or related objects copied) with unique field detection. + +This solves the problem introduced by using `instance.pk = None` and `instance.save()` which results in copying more object state than required. + +## Features + +* 100% test coverage. +* More control over how a model instance should be duplicated +* Multi Database support i.e Create duplicates on one or more databases. +* Restrict fields used for creating a duplicate instance. +* Detects unique fields and naively adds a suffix `copy {count}` to each duplicate instance (for supported fields only). +* Optionally differentiate between a duplicate instance and the original by appending a **copy** suffix to non unique fields (for supported fields only). + +## Table of Contents + +* [Installation](#installation) +* [Usage](#usage) + * [Subclassing the `CloneModel`](#subclassing-the-clonemodel) + * [Using the `CloneMixin`](#using-the-clonemixin) + * [Duplicating a model instance](#duplicating-a-model-instance) + * [Bulk cloning a model](#bulk-cloning-a-model) + * [Creating clones without subclassing `CloneMixin`.](#creating-clones-without-subclassing-clonemixin) + * [CloneMixin attributes](#clonemixin-attributes) + * [Explicit (include only these fields)](#explicit-include-only-these-fields) + * [Implicit (include all except these fields)](#implicit-include-all-except-these-fields) + * [Django Admin](#django-admin) + * [Duplicating Models from the Django Admin view.](#duplicating-models-from-the-django-admin-view) + * [List View](#list-view) + * [Change View](#change-view) + * [CloneModelAdmin class attributes](#clonemodeladmin-class-attributes) +* [Advanced Usage](#advanced-usage) + * [Signals](#signals) + * [pre\_clone\_save, post\_clone\_save](#pre_clone_save-post_clone_save) + * [Clone Many to Many fields](#clone-many-to-many-fields) + * [Using the `CloneModel`](#using-the-clonemodel) + * [Using the `CloneMixin`](#using-the-clonemixin-1) + * [Multi database support](#multi-database-support) +* [Compatibility](#compatibility) +* [Running locally](#running-locally) +* [Found a Bug?](#found-a-bug) +* [Contributors β¨](#contributors-) + +## Installation + + + +## Usage + +### Subclassing the `CloneModel` + + + +### Using the `CloneMixin` + + + +### Duplicating a model instance + + + +### Bulk cloning a model + + + +### Creating clones without subclassing `CloneMixin`. + +> **NOTE:** :warning: +> +> * This method won't copy over related objects like Many to Many/One to Many relationships. +> * Ensure that required fields skipped from being cloned are passed in using the `attrs` kwargs. + + + +### CloneMixin attributes + +| Attribute | Description | +|:------------------------------:|:------------:| +| `DUPLICATE_SUFFIX` | Suffix to append to duplicates <br> (NOTE: This requires `USE_DUPLICATE_SUFFIX_FOR_NON_UNIQUE_FIELDS` <br> to be enabled and supports string fields). | +`USE_DUPLICATE_SUFFIX_FOR_NON_UNIQUE_FIELDS` | Enable appending the `DUPLICATE_SUFFIX` to new cloned instances. | +`UNIQUE_DUPLICATE_SUFFIX` | Suffix to append to unique fields | +`USE_UNIQUE_DUPLICATE_SUFFIX` | Enable appending the `UNIQUE_DUPLICATE_SUFFIX` to new cloned instances. | +`MAX_UNIQUE_DUPLICATE_QUERY_ATTEMPTS` | The max query attempt while generating unique values for a case of unique conflicts. | + +#### Explicit (include only these fields) + +| Attribute | Description | +|:------------------------------:|:------------:| +| `_clone_fields` | Restrict the list of fields to copy from the instance (By default: Copies all fields excluding auto-created/non editable model fields) | +| `_clone_m2m_fields` | Restricted Many to many fields (i.e Test.tags) | +| `_clone_m2o_or_o2m_fields` | Restricted Many to One/One to Many fields | +| `_clone_o2o_fields` | Restricted One to One fields | +| `_clone_linked_m2m_fields` | Restricted Many to Many fields that should be linked to the new instance | + +#### Implicit (include all except these fields) + +| Attribute | Description | +|:--------------------:|:-----------:| +| `_clone_excluded_fields` | Excluded model fields. | +`_clone_excluded_m2m_fields` | Excluded many to many fields. | +`_clone_excluded_m2o_or_o2m_fields` | Excluded Many to One/One to Many fields. | +`_clone_excluded_o2o_fields` | Excluded one to one fields. | + +> **NOTE:** :warning: +> +> * Ensure to either set `_clone_excluded_*` or `_clone_*`. Using both would raise errors. + +### Django Admin + +#### Duplicating Models from the Django Admin view. + + + +##### List View + + + +##### Change View + + + +#### CloneModelAdmin class attributes + + + +> **NOTE:** :warning: +> +> * Ensure that `model_clone` is placed before `django.contrib.admin` + +```python +INSTALLED_APPS = [ + 'model_clone', + 'django.contrib.admin', + '...', +] +``` + +## Advanced Usage + +### Signals + +#### pre\_clone\_save, post\_clone\_save + + + +### Clone Many to Many fields + +#### Using the `CloneModel` + + + +#### Using the `CloneMixin` + + + + + +### Multi database support + + + +## Compatibility + +| Python | Supported version | +|--------------|--------------------| +| Python2.x | `<=2.5.3` | +| Python3.5 | `<=2.9.6` | +| Python3.6+ | All versions | + +| Django | Supported version | +|--------------|---------------------| +| 1.11 | `<=2.7.2` | +| 2.x | All versions | +| 3.x | All versions | + +## Running locally + +```shell +$ git clone git@github.com:tj-django/django-clone.git +$ make default-user +$ make run +``` + +Spins up a django server running the demo app. + +Visit http://127.0.0.1:8000 + +## Found a Bug? + +To file a bug or submit a patch, please head over to [django-clone on github](https://github.com/tj-django/django-clone/issues). + +If you feel generous and want to show some extra appreciation: + +Support me with a :star: + +[![Buy me a coffee][buymeacoffee-shield]][buymeacoffee] + +[buymeacoffee]: https://www.buymeacoffee.com/jackton1 + +[buymeacoffee-shield]: https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png + +## Contributors β¨ + +Thanks goes to these wonderful people: + +<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --> + +<!-- prettier-ignore-start --> + +<!-- markdownlint-disable --> + +<table> + <tbody> + <tr> + <td align="center" valign="top" width="14.28%"><a href="http://gerritneven.nl"><img src="https://avatars1.githubusercontent.com/u/2500973?v=4?s=100" width="100px;" alt="Gerben Neven"/><br /><sub><b>Gerben Neven</b></sub></a><br /><a href="https://github.com/tj-django/django-clone/issues?q=author%3Agerbyzation" title="Bug reports">π</a> <a href="https://github.com/tj-django/django-clone/commits?author=gerbyzation" title="Tests">β οΈ</a> <a href="https://github.com/tj-django/django-clone/commits?author=gerbyzation" title="Code">π»</a></td> + <td align="center" valign="top" width="14.28%"><a href="http://sebastian-kindt.com"><img src="https://avatars1.githubusercontent.com/u/2536081?v=4?s=100" width="100px;" alt="Sebastian Kapunkt"/><br /><sub><b>Sebastian Kapunkt</b></sub></a><br /><a href="https://github.com/tj-django/django-clone/commits?author=SebastianKapunkt" title="Code">π»</a> <a href="https://github.com/tj-django/django-clone/issues?q=author%3ASebastianKapunkt" title="Bug reports">π</a> <a href="https://github.com/tj-django/django-clone/commits?author=SebastianKapunkt" title="Tests">β οΈ</a></td> + <td align="center" valign="top" width="14.28%"><a href="https://github.com/andresp99999"><img src="https://avatars0.githubusercontent.com/u/1036725?v=4?s=100" width="100px;" alt="AndrΓ©s Portillo"/><br /><sub><b>AndrΓ©s Portillo</b></sub></a><br /><a href="https://github.com/tj-django/django-clone/issues?q=author%3Aandresp99999" title="Bug reports">π</a></td> + <td align="center" valign="top" width="14.28%"><a href="https://renovate.whitesourcesoftware.com"><img src="https://avatars0.githubusercontent.com/u/25180681?v=4?s=100" width="100px;" alt="WhiteSource Renovate"/><br /><sub><b>WhiteSource Renovate</b></sub></a><br /><a href="#maintenance-renovate-bot" title="Maintenance">π§</a></td> + <td align="center" valign="top" width="14.28%"><a href="https://github.com/yuekui"><img src="https://avatars2.githubusercontent.com/u/2561450?v=4?s=100" width="100px;" alt="Yuekui"/><br /><sub><b>Yuekui</b></sub></a><br /><a href="https://github.com/tj-django/django-clone/commits?author=yuekui" title="Code">π»</a> <a href="https://github.com/tj-django/django-clone/issues?q=author%3Ayuekui" title="Bug reports">π</a> <a href="https://github.com/tj-django/django-clone/commits?author=yuekui" title="Tests">β οΈ</a> <a href="https://github.com/tj-django/django-clone/commits?author=yuekui" title="Documentation">π</a> <a href="#maintenance-yuekui" title="Maintenance">π§</a></td> + <td align="center" valign="top" width="14.28%"><a href="https://github.com/diesieben07"><img src="https://avatars.githubusercontent.com/u/1915984?v=4?s=100" width="100px;" alt="Take Weiland"/><br /><sub><b>Take Weiland</b></sub></a><br /><a href="https://github.com/tj-django/django-clone/commits?author=diesieben07" title="Tests">β οΈ</a> <a href="https://github.com/tj-django/django-clone/issues?q=author%3Adiesieben07" title="Bug reports">π</a> <a href="https://github.com/tj-django/django-clone/commits?author=diesieben07" title="Code">π»</a></td> + <td align="center" valign="top" width="14.28%"><a href="https://github.com/ptrck"><img src="https://avatars.githubusercontent.com/u/1259703?v=4?s=100" width="100px;" alt="Patrick"/><br /><sub><b>Patrick</b></sub></a><br /><a href="https://github.com/tj-django/django-clone/issues?q=author%3Aptrck" title="Bug reports">π</a> <a href="https://github.com/tj-django/django-clone/commits?author=ptrck" title="Code">π»</a></td> + </tr> + <tr> + <td align="center" valign="top" width="14.28%"><a href="https://github.com/Akollek"><img src="https://avatars.githubusercontent.com/u/5873158?v=4?s=100" width="100px;" alt="Amiel Kollek"/><br /><sub><b>Amiel Kollek</b></sub></a><br /><a href="https://github.com/tj-django/django-clone/commits?author=Akollek" title="Code">π»</a> <a href="https://github.com/tj-django/django-clone/issues?q=author%3AAkollek" title="Bug reports">π</a> <a href="https://github.com/tj-django/django-clone/commits?author=Akollek" title="Tests">β οΈ</a></td> + <td align="center" valign="top" width="14.28%"><a href="https://erictheise.com/"><img src="https://avatars.githubusercontent.com/u/317680?v=4?s=100" width="100px;" alt="Eric Theise"/><br /><sub><b>Eric Theise</b></sub></a><br /><a href="https://github.com/tj-django/django-clone/commits?author=erictheise" title="Documentation">π</a></td> + <td align="center" valign="top" width="14.28%"><a href="https://github.com/DanielSchaffer"><img src="https://avatars.githubusercontent.com/u/334487?v=4?s=100" width="100px;" alt="Daniel Schaffer"/><br /><sub><b>Daniel Schaffer</b></sub></a><br /><a href="https://github.com/tj-django/django-clone/commits?author=DanielSchaffer" title="Code">π»</a> <a href="https://github.com/tj-django/django-clone/commits?author=DanielSchaffer" title="Tests">β οΈ</a></td> + </tr> + </tbody> +</table> + +<!-- markdownlint-restore --> + +<!-- prettier-ignore-end --> + +<!-- ALL-CONTRIBUTORS-LIST:END --> + +This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! + + +%package -n python3-django-clone +Summary: Create a clone of a django model instance. +Provides: python-django-clone +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-django-clone +<p align="center"> + <img width="466" alt="4FC889E9-FF59-4E44-9EB6-2AF7DC034C74" src="https://user-images.githubusercontent.com/17484350/215616634-17439a58-7bd8-4e9c-989f-e6bef7c73e48.png"> +</p> + +| Python | Django | Downloads | Code Style | +|:---------:|:-------:|:-----------:|:--------------:| +| [](https://pypi.org/project/django-clone) | [](https://docs.djangoproject.com/en/3.2/releases/) | [](https://pepy.tech/project/django-clone) | [](https://github.com/psf/black) | + +| PyPI | Test | Vulnerabilities | Coverage | Code Quality | Pre-Commit | +|:---------------:|:----:|:---------------:|:--------:|:-------------:|:-------------:| +| [](https://badge.fury.io/py/django-clone) | [](https://github.com/tj-django/django-clone/actions?query=workflow%3ATest) | [](https://snyk.io/test/github/tj-django/django-clone?targetFile=requirements.txt) | [](https://www.codacy.com/gh/tj-django/django-clone?utm_source=github.com\&utm_medium=referral\&utm_content=tj-django/django-clone\&utm_campaign=Badge_Coverage) <br/> [](https://codecov.io/gh/tj-django/django-clone)| [](https://www.codacy.com/gh/tj-django/django-clone?utm_source=github.com\&utm_medium=referral\&utm_content=tj-django/django-clone\&utm_campaign=Badge_Grade) | [](https://results.pre-commit.ci/latest/github/tj-django/django-clone/main) | + +## django-clone + +Create copies of a model instance with explicit control on how the instance should be duplicated (limiting fields or related objects copied) with unique field detection. + +This solves the problem introduced by using `instance.pk = None` and `instance.save()` which results in copying more object state than required. + +## Features + +* 100% test coverage. +* More control over how a model instance should be duplicated +* Multi Database support i.e Create duplicates on one or more databases. +* Restrict fields used for creating a duplicate instance. +* Detects unique fields and naively adds a suffix `copy {count}` to each duplicate instance (for supported fields only). +* Optionally differentiate between a duplicate instance and the original by appending a **copy** suffix to non unique fields (for supported fields only). + +## Table of Contents + +* [Installation](#installation) +* [Usage](#usage) + * [Subclassing the `CloneModel`](#subclassing-the-clonemodel) + * [Using the `CloneMixin`](#using-the-clonemixin) + * [Duplicating a model instance](#duplicating-a-model-instance) + * [Bulk cloning a model](#bulk-cloning-a-model) + * [Creating clones without subclassing `CloneMixin`.](#creating-clones-without-subclassing-clonemixin) + * [CloneMixin attributes](#clonemixin-attributes) + * [Explicit (include only these fields)](#explicit-include-only-these-fields) + * [Implicit (include all except these fields)](#implicit-include-all-except-these-fields) + * [Django Admin](#django-admin) + * [Duplicating Models from the Django Admin view.](#duplicating-models-from-the-django-admin-view) + * [List View](#list-view) + * [Change View](#change-view) + * [CloneModelAdmin class attributes](#clonemodeladmin-class-attributes) +* [Advanced Usage](#advanced-usage) + * [Signals](#signals) + * [pre\_clone\_save, post\_clone\_save](#pre_clone_save-post_clone_save) + * [Clone Many to Many fields](#clone-many-to-many-fields) + * [Using the `CloneModel`](#using-the-clonemodel) + * [Using the `CloneMixin`](#using-the-clonemixin-1) + * [Multi database support](#multi-database-support) +* [Compatibility](#compatibility) +* [Running locally](#running-locally) +* [Found a Bug?](#found-a-bug) +* [Contributors β¨](#contributors-) + +## Installation + + + +## Usage + +### Subclassing the `CloneModel` + + + +### Using the `CloneMixin` + + + +### Duplicating a model instance + + + +### Bulk cloning a model + + + +### Creating clones without subclassing `CloneMixin`. + +> **NOTE:** :warning: +> +> * This method won't copy over related objects like Many to Many/One to Many relationships. +> * Ensure that required fields skipped from being cloned are passed in using the `attrs` kwargs. + + + +### CloneMixin attributes + +| Attribute | Description | +|:------------------------------:|:------------:| +| `DUPLICATE_SUFFIX` | Suffix to append to duplicates <br> (NOTE: This requires `USE_DUPLICATE_SUFFIX_FOR_NON_UNIQUE_FIELDS` <br> to be enabled and supports string fields). | +`USE_DUPLICATE_SUFFIX_FOR_NON_UNIQUE_FIELDS` | Enable appending the `DUPLICATE_SUFFIX` to new cloned instances. | +`UNIQUE_DUPLICATE_SUFFIX` | Suffix to append to unique fields | +`USE_UNIQUE_DUPLICATE_SUFFIX` | Enable appending the `UNIQUE_DUPLICATE_SUFFIX` to new cloned instances. | +`MAX_UNIQUE_DUPLICATE_QUERY_ATTEMPTS` | The max query attempt while generating unique values for a case of unique conflicts. | + +#### Explicit (include only these fields) + +| Attribute | Description | +|:------------------------------:|:------------:| +| `_clone_fields` | Restrict the list of fields to copy from the instance (By default: Copies all fields excluding auto-created/non editable model fields) | +| `_clone_m2m_fields` | Restricted Many to many fields (i.e Test.tags) | +| `_clone_m2o_or_o2m_fields` | Restricted Many to One/One to Many fields | +| `_clone_o2o_fields` | Restricted One to One fields | +| `_clone_linked_m2m_fields` | Restricted Many to Many fields that should be linked to the new instance | + +#### Implicit (include all except these fields) + +| Attribute | Description | +|:--------------------:|:-----------:| +| `_clone_excluded_fields` | Excluded model fields. | +`_clone_excluded_m2m_fields` | Excluded many to many fields. | +`_clone_excluded_m2o_or_o2m_fields` | Excluded Many to One/One to Many fields. | +`_clone_excluded_o2o_fields` | Excluded one to one fields. | + +> **NOTE:** :warning: +> +> * Ensure to either set `_clone_excluded_*` or `_clone_*`. Using both would raise errors. + +### Django Admin + +#### Duplicating Models from the Django Admin view. + + + +##### List View + + + +##### Change View + + + +#### CloneModelAdmin class attributes + + + +> **NOTE:** :warning: +> +> * Ensure that `model_clone` is placed before `django.contrib.admin` + +```python +INSTALLED_APPS = [ + 'model_clone', + 'django.contrib.admin', + '...', +] +``` + +## Advanced Usage + +### Signals + +#### pre\_clone\_save, post\_clone\_save + + + +### Clone Many to Many fields + +#### Using the `CloneModel` + + + +#### Using the `CloneMixin` + + + + + +### Multi database support + + + +## Compatibility + +| Python | Supported version | +|--------------|--------------------| +| Python2.x | `<=2.5.3` | +| Python3.5 | `<=2.9.6` | +| Python3.6+ | All versions | + +| Django | Supported version | +|--------------|---------------------| +| 1.11 | `<=2.7.2` | +| 2.x | All versions | +| 3.x | All versions | + +## Running locally + +```shell +$ git clone git@github.com:tj-django/django-clone.git +$ make default-user +$ make run +``` + +Spins up a django server running the demo app. + +Visit http://127.0.0.1:8000 + +## Found a Bug? + +To file a bug or submit a patch, please head over to [django-clone on github](https://github.com/tj-django/django-clone/issues). + +If you feel generous and want to show some extra appreciation: + +Support me with a :star: + +[![Buy me a coffee][buymeacoffee-shield]][buymeacoffee] + +[buymeacoffee]: https://www.buymeacoffee.com/jackton1 + +[buymeacoffee-shield]: https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png + +## Contributors β¨ + +Thanks goes to these wonderful people: + +<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --> + +<!-- prettier-ignore-start --> + +<!-- markdownlint-disable --> + +<table> + <tbody> + <tr> + <td align="center" valign="top" width="14.28%"><a href="http://gerritneven.nl"><img src="https://avatars1.githubusercontent.com/u/2500973?v=4?s=100" width="100px;" alt="Gerben Neven"/><br /><sub><b>Gerben Neven</b></sub></a><br /><a href="https://github.com/tj-django/django-clone/issues?q=author%3Agerbyzation" title="Bug reports">π</a> <a href="https://github.com/tj-django/django-clone/commits?author=gerbyzation" title="Tests">β οΈ</a> <a href="https://github.com/tj-django/django-clone/commits?author=gerbyzation" title="Code">π»</a></td> + <td align="center" valign="top" width="14.28%"><a href="http://sebastian-kindt.com"><img src="https://avatars1.githubusercontent.com/u/2536081?v=4?s=100" width="100px;" alt="Sebastian Kapunkt"/><br /><sub><b>Sebastian Kapunkt</b></sub></a><br /><a href="https://github.com/tj-django/django-clone/commits?author=SebastianKapunkt" title="Code">π»</a> <a href="https://github.com/tj-django/django-clone/issues?q=author%3ASebastianKapunkt" title="Bug reports">π</a> <a href="https://github.com/tj-django/django-clone/commits?author=SebastianKapunkt" title="Tests">β οΈ</a></td> + <td align="center" valign="top" width="14.28%"><a href="https://github.com/andresp99999"><img src="https://avatars0.githubusercontent.com/u/1036725?v=4?s=100" width="100px;" alt="AndrΓ©s Portillo"/><br /><sub><b>AndrΓ©s Portillo</b></sub></a><br /><a href="https://github.com/tj-django/django-clone/issues?q=author%3Aandresp99999" title="Bug reports">π</a></td> + <td align="center" valign="top" width="14.28%"><a href="https://renovate.whitesourcesoftware.com"><img src="https://avatars0.githubusercontent.com/u/25180681?v=4?s=100" width="100px;" alt="WhiteSource Renovate"/><br /><sub><b>WhiteSource Renovate</b></sub></a><br /><a href="#maintenance-renovate-bot" title="Maintenance">π§</a></td> + <td align="center" valign="top" width="14.28%"><a href="https://github.com/yuekui"><img src="https://avatars2.githubusercontent.com/u/2561450?v=4?s=100" width="100px;" alt="Yuekui"/><br /><sub><b>Yuekui</b></sub></a><br /><a href="https://github.com/tj-django/django-clone/commits?author=yuekui" title="Code">π»</a> <a href="https://github.com/tj-django/django-clone/issues?q=author%3Ayuekui" title="Bug reports">π</a> <a href="https://github.com/tj-django/django-clone/commits?author=yuekui" title="Tests">β οΈ</a> <a href="https://github.com/tj-django/django-clone/commits?author=yuekui" title="Documentation">π</a> <a href="#maintenance-yuekui" title="Maintenance">π§</a></td> + <td align="center" valign="top" width="14.28%"><a href="https://github.com/diesieben07"><img src="https://avatars.githubusercontent.com/u/1915984?v=4?s=100" width="100px;" alt="Take Weiland"/><br /><sub><b>Take Weiland</b></sub></a><br /><a href="https://github.com/tj-django/django-clone/commits?author=diesieben07" title="Tests">β οΈ</a> <a href="https://github.com/tj-django/django-clone/issues?q=author%3Adiesieben07" title="Bug reports">π</a> <a href="https://github.com/tj-django/django-clone/commits?author=diesieben07" title="Code">π»</a></td> + <td align="center" valign="top" width="14.28%"><a href="https://github.com/ptrck"><img src="https://avatars.githubusercontent.com/u/1259703?v=4?s=100" width="100px;" alt="Patrick"/><br /><sub><b>Patrick</b></sub></a><br /><a href="https://github.com/tj-django/django-clone/issues?q=author%3Aptrck" title="Bug reports">π</a> <a href="https://github.com/tj-django/django-clone/commits?author=ptrck" title="Code">π»</a></td> + </tr> + <tr> + <td align="center" valign="top" width="14.28%"><a href="https://github.com/Akollek"><img src="https://avatars.githubusercontent.com/u/5873158?v=4?s=100" width="100px;" alt="Amiel Kollek"/><br /><sub><b>Amiel Kollek</b></sub></a><br /><a href="https://github.com/tj-django/django-clone/commits?author=Akollek" title="Code">π»</a> <a href="https://github.com/tj-django/django-clone/issues?q=author%3AAkollek" title="Bug reports">π</a> <a href="https://github.com/tj-django/django-clone/commits?author=Akollek" title="Tests">β οΈ</a></td> + <td align="center" valign="top" width="14.28%"><a href="https://erictheise.com/"><img src="https://avatars.githubusercontent.com/u/317680?v=4?s=100" width="100px;" alt="Eric Theise"/><br /><sub><b>Eric Theise</b></sub></a><br /><a href="https://github.com/tj-django/django-clone/commits?author=erictheise" title="Documentation">π</a></td> + <td align="center" valign="top" width="14.28%"><a href="https://github.com/DanielSchaffer"><img src="https://avatars.githubusercontent.com/u/334487?v=4?s=100" width="100px;" alt="Daniel Schaffer"/><br /><sub><b>Daniel Schaffer</b></sub></a><br /><a href="https://github.com/tj-django/django-clone/commits?author=DanielSchaffer" title="Code">π»</a> <a href="https://github.com/tj-django/django-clone/commits?author=DanielSchaffer" title="Tests">β οΈ</a></td> + </tr> + </tbody> +</table> + +<!-- markdownlint-restore --> + +<!-- prettier-ignore-end --> + +<!-- ALL-CONTRIBUTORS-LIST:END --> + +This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! + + +%package help +Summary: Development documents and examples for django-clone +Provides: python3-django-clone-doc +%description help +<p align="center"> + <img width="466" alt="4FC889E9-FF59-4E44-9EB6-2AF7DC034C74" src="https://user-images.githubusercontent.com/17484350/215616634-17439a58-7bd8-4e9c-989f-e6bef7c73e48.png"> +</p> + +| Python | Django | Downloads | Code Style | +|:---------:|:-------:|:-----------:|:--------------:| +| [](https://pypi.org/project/django-clone) | [](https://docs.djangoproject.com/en/3.2/releases/) | [](https://pepy.tech/project/django-clone) | [](https://github.com/psf/black) | + +| PyPI | Test | Vulnerabilities | Coverage | Code Quality | Pre-Commit | +|:---------------:|:----:|:---------------:|:--------:|:-------------:|:-------------:| +| [](https://badge.fury.io/py/django-clone) | [](https://github.com/tj-django/django-clone/actions?query=workflow%3ATest) | [](https://snyk.io/test/github/tj-django/django-clone?targetFile=requirements.txt) | [](https://www.codacy.com/gh/tj-django/django-clone?utm_source=github.com\&utm_medium=referral\&utm_content=tj-django/django-clone\&utm_campaign=Badge_Coverage) <br/> [](https://codecov.io/gh/tj-django/django-clone)| [](https://www.codacy.com/gh/tj-django/django-clone?utm_source=github.com\&utm_medium=referral\&utm_content=tj-django/django-clone\&utm_campaign=Badge_Grade) | [](https://results.pre-commit.ci/latest/github/tj-django/django-clone/main) | + +## django-clone + +Create copies of a model instance with explicit control on how the instance should be duplicated (limiting fields or related objects copied) with unique field detection. + +This solves the problem introduced by using `instance.pk = None` and `instance.save()` which results in copying more object state than required. + +## Features + +* 100% test coverage. +* More control over how a model instance should be duplicated +* Multi Database support i.e Create duplicates on one or more databases. +* Restrict fields used for creating a duplicate instance. +* Detects unique fields and naively adds a suffix `copy {count}` to each duplicate instance (for supported fields only). +* Optionally differentiate between a duplicate instance and the original by appending a **copy** suffix to non unique fields (for supported fields only). + +## Table of Contents + +* [Installation](#installation) +* [Usage](#usage) + * [Subclassing the `CloneModel`](#subclassing-the-clonemodel) + * [Using the `CloneMixin`](#using-the-clonemixin) + * [Duplicating a model instance](#duplicating-a-model-instance) + * [Bulk cloning a model](#bulk-cloning-a-model) + * [Creating clones without subclassing `CloneMixin`.](#creating-clones-without-subclassing-clonemixin) + * [CloneMixin attributes](#clonemixin-attributes) + * [Explicit (include only these fields)](#explicit-include-only-these-fields) + * [Implicit (include all except these fields)](#implicit-include-all-except-these-fields) + * [Django Admin](#django-admin) + * [Duplicating Models from the Django Admin view.](#duplicating-models-from-the-django-admin-view) + * [List View](#list-view) + * [Change View](#change-view) + * [CloneModelAdmin class attributes](#clonemodeladmin-class-attributes) +* [Advanced Usage](#advanced-usage) + * [Signals](#signals) + * [pre\_clone\_save, post\_clone\_save](#pre_clone_save-post_clone_save) + * [Clone Many to Many fields](#clone-many-to-many-fields) + * [Using the `CloneModel`](#using-the-clonemodel) + * [Using the `CloneMixin`](#using-the-clonemixin-1) + * [Multi database support](#multi-database-support) +* [Compatibility](#compatibility) +* [Running locally](#running-locally) +* [Found a Bug?](#found-a-bug) +* [Contributors β¨](#contributors-) + +## Installation + + + +## Usage + +### Subclassing the `CloneModel` + + + +### Using the `CloneMixin` + + + +### Duplicating a model instance + + + +### Bulk cloning a model + + + +### Creating clones without subclassing `CloneMixin`. + +> **NOTE:** :warning: +> +> * This method won't copy over related objects like Many to Many/One to Many relationships. +> * Ensure that required fields skipped from being cloned are passed in using the `attrs` kwargs. + + + +### CloneMixin attributes + +| Attribute | Description | +|:------------------------------:|:------------:| +| `DUPLICATE_SUFFIX` | Suffix to append to duplicates <br> (NOTE: This requires `USE_DUPLICATE_SUFFIX_FOR_NON_UNIQUE_FIELDS` <br> to be enabled and supports string fields). | +`USE_DUPLICATE_SUFFIX_FOR_NON_UNIQUE_FIELDS` | Enable appending the `DUPLICATE_SUFFIX` to new cloned instances. | +`UNIQUE_DUPLICATE_SUFFIX` | Suffix to append to unique fields | +`USE_UNIQUE_DUPLICATE_SUFFIX` | Enable appending the `UNIQUE_DUPLICATE_SUFFIX` to new cloned instances. | +`MAX_UNIQUE_DUPLICATE_QUERY_ATTEMPTS` | The max query attempt while generating unique values for a case of unique conflicts. | + +#### Explicit (include only these fields) + +| Attribute | Description | +|:------------------------------:|:------------:| +| `_clone_fields` | Restrict the list of fields to copy from the instance (By default: Copies all fields excluding auto-created/non editable model fields) | +| `_clone_m2m_fields` | Restricted Many to many fields (i.e Test.tags) | +| `_clone_m2o_or_o2m_fields` | Restricted Many to One/One to Many fields | +| `_clone_o2o_fields` | Restricted One to One fields | +| `_clone_linked_m2m_fields` | Restricted Many to Many fields that should be linked to the new instance | + +#### Implicit (include all except these fields) + +| Attribute | Description | +|:--------------------:|:-----------:| +| `_clone_excluded_fields` | Excluded model fields. | +`_clone_excluded_m2m_fields` | Excluded many to many fields. | +`_clone_excluded_m2o_or_o2m_fields` | Excluded Many to One/One to Many fields. | +`_clone_excluded_o2o_fields` | Excluded one to one fields. | + +> **NOTE:** :warning: +> +> * Ensure to either set `_clone_excluded_*` or `_clone_*`. Using both would raise errors. + +### Django Admin + +#### Duplicating Models from the Django Admin view. + + + +##### List View + + + +##### Change View + + + +#### CloneModelAdmin class attributes + + + +> **NOTE:** :warning: +> +> * Ensure that `model_clone` is placed before `django.contrib.admin` + +```python +INSTALLED_APPS = [ + 'model_clone', + 'django.contrib.admin', + '...', +] +``` + +## Advanced Usage + +### Signals + +#### pre\_clone\_save, post\_clone\_save + + + +### Clone Many to Many fields + +#### Using the `CloneModel` + + + +#### Using the `CloneMixin` + + + + + +### Multi database support + + + +## Compatibility + +| Python | Supported version | +|--------------|--------------------| +| Python2.x | `<=2.5.3` | +| Python3.5 | `<=2.9.6` | +| Python3.6+ | All versions | + +| Django | Supported version | +|--------------|---------------------| +| 1.11 | `<=2.7.2` | +| 2.x | All versions | +| 3.x | All versions | + +## Running locally + +```shell +$ git clone git@github.com:tj-django/django-clone.git +$ make default-user +$ make run +``` + +Spins up a django server running the demo app. + +Visit http://127.0.0.1:8000 + +## Found a Bug? + +To file a bug or submit a patch, please head over to [django-clone on github](https://github.com/tj-django/django-clone/issues). + +If you feel generous and want to show some extra appreciation: + +Support me with a :star: + +[![Buy me a coffee][buymeacoffee-shield]][buymeacoffee] + +[buymeacoffee]: https://www.buymeacoffee.com/jackton1 + +[buymeacoffee-shield]: https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png + +## Contributors β¨ + +Thanks goes to these wonderful people: + +<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --> + +<!-- prettier-ignore-start --> + +<!-- markdownlint-disable --> + +<table> + <tbody> + <tr> + <td align="center" valign="top" width="14.28%"><a href="http://gerritneven.nl"><img src="https://avatars1.githubusercontent.com/u/2500973?v=4?s=100" width="100px;" alt="Gerben Neven"/><br /><sub><b>Gerben Neven</b></sub></a><br /><a href="https://github.com/tj-django/django-clone/issues?q=author%3Agerbyzation" title="Bug reports">π</a> <a href="https://github.com/tj-django/django-clone/commits?author=gerbyzation" title="Tests">β οΈ</a> <a href="https://github.com/tj-django/django-clone/commits?author=gerbyzation" title="Code">π»</a></td> + <td align="center" valign="top" width="14.28%"><a href="http://sebastian-kindt.com"><img src="https://avatars1.githubusercontent.com/u/2536081?v=4?s=100" width="100px;" alt="Sebastian Kapunkt"/><br /><sub><b>Sebastian Kapunkt</b></sub></a><br /><a href="https://github.com/tj-django/django-clone/commits?author=SebastianKapunkt" title="Code">π»</a> <a href="https://github.com/tj-django/django-clone/issues?q=author%3ASebastianKapunkt" title="Bug reports">π</a> <a href="https://github.com/tj-django/django-clone/commits?author=SebastianKapunkt" title="Tests">β οΈ</a></td> + <td align="center" valign="top" width="14.28%"><a href="https://github.com/andresp99999"><img src="https://avatars0.githubusercontent.com/u/1036725?v=4?s=100" width="100px;" alt="AndrΓ©s Portillo"/><br /><sub><b>AndrΓ©s Portillo</b></sub></a><br /><a href="https://github.com/tj-django/django-clone/issues?q=author%3Aandresp99999" title="Bug reports">π</a></td> + <td align="center" valign="top" width="14.28%"><a href="https://renovate.whitesourcesoftware.com"><img src="https://avatars0.githubusercontent.com/u/25180681?v=4?s=100" width="100px;" alt="WhiteSource Renovate"/><br /><sub><b>WhiteSource Renovate</b></sub></a><br /><a href="#maintenance-renovate-bot" title="Maintenance">π§</a></td> + <td align="center" valign="top" width="14.28%"><a href="https://github.com/yuekui"><img src="https://avatars2.githubusercontent.com/u/2561450?v=4?s=100" width="100px;" alt="Yuekui"/><br /><sub><b>Yuekui</b></sub></a><br /><a href="https://github.com/tj-django/django-clone/commits?author=yuekui" title="Code">π»</a> <a href="https://github.com/tj-django/django-clone/issues?q=author%3Ayuekui" title="Bug reports">π</a> <a href="https://github.com/tj-django/django-clone/commits?author=yuekui" title="Tests">β οΈ</a> <a href="https://github.com/tj-django/django-clone/commits?author=yuekui" title="Documentation">π</a> <a href="#maintenance-yuekui" title="Maintenance">π§</a></td> + <td align="center" valign="top" width="14.28%"><a href="https://github.com/diesieben07"><img src="https://avatars.githubusercontent.com/u/1915984?v=4?s=100" width="100px;" alt="Take Weiland"/><br /><sub><b>Take Weiland</b></sub></a><br /><a href="https://github.com/tj-django/django-clone/commits?author=diesieben07" title="Tests">β οΈ</a> <a href="https://github.com/tj-django/django-clone/issues?q=author%3Adiesieben07" title="Bug reports">π</a> <a href="https://github.com/tj-django/django-clone/commits?author=diesieben07" title="Code">π»</a></td> + <td align="center" valign="top" width="14.28%"><a href="https://github.com/ptrck"><img src="https://avatars.githubusercontent.com/u/1259703?v=4?s=100" width="100px;" alt="Patrick"/><br /><sub><b>Patrick</b></sub></a><br /><a href="https://github.com/tj-django/django-clone/issues?q=author%3Aptrck" title="Bug reports">π</a> <a href="https://github.com/tj-django/django-clone/commits?author=ptrck" title="Code">π»</a></td> + </tr> + <tr> + <td align="center" valign="top" width="14.28%"><a href="https://github.com/Akollek"><img src="https://avatars.githubusercontent.com/u/5873158?v=4?s=100" width="100px;" alt="Amiel Kollek"/><br /><sub><b>Amiel Kollek</b></sub></a><br /><a href="https://github.com/tj-django/django-clone/commits?author=Akollek" title="Code">π»</a> <a href="https://github.com/tj-django/django-clone/issues?q=author%3AAkollek" title="Bug reports">π</a> <a href="https://github.com/tj-django/django-clone/commits?author=Akollek" title="Tests">β οΈ</a></td> + <td align="center" valign="top" width="14.28%"><a href="https://erictheise.com/"><img src="https://avatars.githubusercontent.com/u/317680?v=4?s=100" width="100px;" alt="Eric Theise"/><br /><sub><b>Eric Theise</b></sub></a><br /><a href="https://github.com/tj-django/django-clone/commits?author=erictheise" title="Documentation">π</a></td> + <td align="center" valign="top" width="14.28%"><a href="https://github.com/DanielSchaffer"><img src="https://avatars.githubusercontent.com/u/334487?v=4?s=100" width="100px;" alt="Daniel Schaffer"/><br /><sub><b>Daniel Schaffer</b></sub></a><br /><a href="https://github.com/tj-django/django-clone/commits?author=DanielSchaffer" title="Code">π»</a> <a href="https://github.com/tj-django/django-clone/commits?author=DanielSchaffer" title="Tests">β οΈ</a></td> + </tr> + </tbody> +</table> + +<!-- markdownlint-restore --> + +<!-- prettier-ignore-end --> + +<!-- ALL-CONTRIBUTORS-LIST:END --> + +This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! + + +%prep +%autosetup -n django-clone-5.3.1 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-django-clone -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Wed Apr 12 2023 Python_Bot <Python_Bot@openeuler.org> - 5.3.1-1 +- Package Spec generated |
