Skip to content

Commit

Permalink
Merge pull request #243 from tj-django/chore/update-docs
Browse files Browse the repository at this point in the history
Updated docs
  • Loading branch information
jackton1 committed Mar 24, 2021
2 parents ba1aa88 + 2e61418 commit df2595e
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 28 deletions.
16 changes: 16 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [v2.0.2](https://github.com/tj-django/django-clone/releases/tag/v2.0.2) - 2021-03-24

<small>[Compare with v2.0.1](https://github.com/tj-django/django-clone/compare/v2.0.1...v2.0.2)</small>

### Fixed
- Fix code style issues with black ([1a450ef](https://github.com/tj-django/django-clone/commit/1a450ef545aa04d17de1db74720d4e110e476a98) by Lint Action).
- Fixed test ([34a77e6](https://github.com/tj-django/django-clone/commit/34a77e68133c1f417947f408818decafd074ada6) by Tonye Jack).
- Fixed lint errors. ([5f4b4ea](https://github.com/tj-django/django-clone/commit/5f4b4eae1c313565cad43efea6d38c2c41e8671b) by Tonye Jack).
- Fixed bug with cloning slugs. ([bdb6029](https://github.com/tj-django/django-clone/commit/bdb60295f84359ed9f43fea31af2f0c076c5d623) by Tonye Jack).
- Fixed short description. ([64ce104](https://github.com/tj-django/django-clone/commit/64ce104f03c5718a1e5b95e256b5d50700ff8803) by Tonye Jack).
- Fixed migrations. ([4ede994](https://github.com/tj-django/django-clone/commit/4ede9947c2a6528598766a7b3cec04fb105d03b6) by Tonye Jack).
- Fixed type hints. ([afae2d7](https://github.com/tj-django/django-clone/commit/afae2d7f9dd46f3394015a142f9a85d4d45e0ea8) by Tonye Jack).
- Fixed clean. ([3ead462](https://github.com/tj-django/django-clone/commit/3ead462bc16c79594609539de73aa89a51019f5a) by Tonye Jack).
- Fixed imports. ([5e04253](https://github.com/tj-django/django-clone/commit/5e042538055ed9860cd2bd9d78cd7683dc4cd376) by Tonye Jack).


## [v2.0.1](https://github.com/tj-django/django-clone/releases/tag/v2.0.1) - 2021-03-24

<small>[Compare with v2.0.0](https://github.com/tj-django/django-clone/compare/v2.0.0...v2.0.1)</small>
Expand Down
82 changes: 54 additions & 28 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,62 @@
django-clone
------------

Create copies of a model instance with explicit control on how the instance should be duplicated (limiting fields or related objects) copied and unique field detection.
## django-clone

Create copies of a model instance with explicit control on how the instance should be duplicated (limiting fields or related objects) copied and unique field detection.

| PyPI | Python | Django | Downloads | Dependencies |
|:------------------------------:|:---------:|:-------:|:-----------:|:-------------:|
| [![PyPI version](https://badge.fury.io/py/django-clone.svg)](https://badge.fury.io/py/django-clone) | [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/django_clone.svg)](https://pypi.org/project/django-clone) | [![PyPI - Django Version](https://img.shields.io/pypi/djversions/django_clone.svg)](https://docs.djangoproject.com/en/3.0/releases/) | [![Downloads](https://pepy.tech/badge/django-clone)](https://pepy.tech/project/django-clone) | [![Updates](https://pyup.io/repos/github/tj-django/django-clone/shield.svg)](https://pyup.io/repos/github/tj-django/django-clone/) |



| Test | Vulnerabilities | Coverage | Code Quality | Contributors | Code Style |
|:----:|:---------------:|:--------:|:-------------:|:-------------:| :------------:|
| [![Test](https://github.com/tj-django/django-clone/workflows/Test/badge.svg)](https://github.com/tj-django/django-clone/actions?query=workflow%3ATest) | [![Known Vulnerabilities](https://snyk.io/test/github/tj-django/django-clone/badge.svg?targetFile=requirements.txt)](https://snyk.io/test/github/tj-django/django-clone?targetFile=requirements.txt) | [![Codacy Badge](https://app.codacy.com/project/badge/Coverage/b33dd02dbb034d7fa9886a99f5383ea6)](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/> [![codecov](https://codecov.io/gh/tj-django/django-clone/branch/master/graph/badge.svg?token=2NE21Oe50Q)](https://codecov.io/gh/tj-django/django-clone)| [![Codacy Badge](https://app.codacy.com/project/badge/Grade/b33dd02dbb034d7fa9886a99f5383ea6)](https://www.codacy.com/gh/tj-django/django-clone?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=tj-django/django-clone&amp;utm_campaign=Badge_Grade) | [![All Contributors](https://img.shields.io/badge/all_contributors-5-orange.svg?style=flat-square)](#contributors) | [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

| [![Test](https://github.com/tj-django/django-clone/workflows/Test/badge.svg)](https://github.com/tj-django/django-clone/actions?query=workflow%3ATest) | [![Known Vulnerabilities](https://snyk.io/test/github/tj-django/django-clone/badge.svg?targetFile=requirements.txt)](https://snyk.io/test/github/tj-django/django-clone?targetFile=requirements.txt) | [![Codacy Badge](https://app.codacy.com/project/badge/Coverage/b33dd02dbb034d7fa9886a99f5383ea6)](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/> [![codecov](https://codecov.io/gh/tj-django/django-clone/branch/master/graph/badge.svg?token=2NE21Oe50Q)](https://codecov.io/gh/tj-django/django-clone)| [![Codacy Badge](https://app.codacy.com/project/badge/Grade/b33dd02dbb034d7fa9886a99f5383ea6)](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) | [![All Contributors](https://img.shields.io/badge/all_contributors-5-orange.svg?style=flat-square)](#contributors) | [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

## Table of contents

- [Installation](#Installation)
* [Installation](#installation)

* [Usage](#usage)

* [Inheriting from `CloneModel` or `CloneMixin`](#inheriting-from-clonemodel-or-clonemixin)

* [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)

* [CloneMixin attributes](#clonemixin-attributes)

* [Explicit](#explicit)
* [Implicit](#implicit)

* [Creating clones without subclassing `CloneMixin`.](#creating-clones-without-subclassing-clonemixin)

* [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)

- [Usage](#Usage)
- [Duplicating a Model Instance](#duplicating-a-model-instance)
- [Using the CloneMixin](#clonemixin-attributes)
- [Creating clones without subclassing `CloneMixin`](#creating-clones-without-subclassing-clonemixin)
- [Duplicating Models from Django Admin view](#duplicating-models-from-django-admin-view)
* [CloneModelAdmin class attributes](#clonemodeladmin-class-attributes)

- [CHANGELOG](./CHANGELOG.md)
* [Found a Bug?](#found-a-bug)

* [Contributors ✨](#contributors-)

## Installation

Run
Run

```bash script
pip install django-clone
```


## Usage

### Inheriting from `CloneModel` or `CloneMixin`

#### Subclassing the `CloneModel`

```python
Expand Down Expand Up @@ -152,7 +172,7 @@ Out[11]: <QuerySet [<Tag: men>, <Tag: women>]>
|:------------------------------:|:------------:|
| `_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_m2o_or_o2m_fields` | Restricted Many to One/One to Many fields |
`_clone_o2o_fields` | Restricted One to One fields |

#### Implicit
Expand All @@ -164,8 +184,7 @@ Out[11]: <QuerySet [<Tag: men>, <Tag: women>]>
`_clone_excluded_m2o_or_o2m_fields` | Excluded Many to One/One to Many fields. |
`_clone_excluded_o2o_fields` | Excluded one to one fields. |


> :warning: NOTE: Ensure to either set `_clone_excluded_*` or `_clone_*`. Using both would raise errors.
> :warning: NOTE: Ensure to either set `_clone_excluded_*` or `_clone_*`. Using both would raise errors.
### Creating clones without subclassing `CloneMixin`.

Expand Down Expand Up @@ -201,10 +220,13 @@ Out[11]: <QuerySet []>
```

> :warning: NOTE:
> - 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` dictionary.
>
> * 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` dictionary.
### Django Admin

### Duplicating Models from Django Admin view.
#### Duplicating Models from the Django Admin view.

Change

Expand All @@ -227,15 +249,15 @@ class TestModelAdmin(CloneModelAdmin):
pass
```

#### List View
##### List View

![Screenshot](Duplicate-action.png)

#### Change View
##### Change View

![Screenshot](Duplicate-button.png)

### CloneModelAdmin class attributes
#### CloneModelAdmin class attributes

```python

Expand All @@ -249,7 +271,6 @@ class TestModelAdmin(CloneModelAdmin):
include_duplicate_object_link = True
```


> :warning: NOTE: Ensure that `model_clone` is placed before `django.contrib.admin`
```python
Expand All @@ -261,16 +282,19 @@ INSTALLED_APPS = [
```

## Found a Bug?
To file a bug or submit a patch, please head over to [django-clone on github](https://github.com/jackton1/django-clone/issues).

To file a bug or submit a patch, please head over to [django-clone on github](https://github.com/jackton1/django-clone/issues).

## Contributors ✨

Thanks goes to these wonderful people:

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->

<!-- prettier-ignore-start -->

<!-- markdownlint-disable -->

<table>
<tr>
<td align="center"><a href="http://gerritneven.nl"><img src="https://avatars1.githubusercontent.com/u/2500973?v=4" width="100px;" alt=""/><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>
Expand All @@ -282,7 +306,9 @@ Thanks goes to these wonderful people:
</table>

<!-- markdownlint-enable -->

<!-- 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!

0 comments on commit df2595e

Please sign in to comment.