A simple Django app to duplicate model instance in admin.
Project description
=====
Model Duplication
=====
Django admin have `save_as` feature, but that feature have bug with images field, and sometime you want 100% duplication of a model instance with all other related objects and customization, then `save_as` doesn't fit for that purpose.
Quick start
-----------
1. Add "modelduplication" to your INSTALLED_APPS setting like this::
```python
INSTALLED_APPS = [
...
'modelduplication',
]
```
2. Define `pre_duplicate` and `post_duplicate` to your models to customize duplication process
```python
class Book(models.Model):
def pre_duplicate(self, origin):
"""This method use to modify object before `save` on duplication.
:type origin models.Model
:param origin the origin instance
"""
pass
def post_duplicate(self, origin):
"""This method is called after finishing the duplication.
:type origin models.Model
:param origin the origin instance
"""
pass
```
Model Duplication
=====
Django admin have `save_as` feature, but that feature have bug with images field, and sometime you want 100% duplication of a model instance with all other related objects and customization, then `save_as` doesn't fit for that purpose.
Quick start
-----------
1. Add "modelduplication" to your INSTALLED_APPS setting like this::
```python
INSTALLED_APPS = [
...
'modelduplication',
]
```
2. Define `pre_duplicate` and `post_duplicate` to your models to customize duplication process
```python
class Book(models.Model):
def pre_duplicate(self, origin):
"""This method use to modify object before `save` on duplication.
:type origin models.Model
:param origin the origin instance
"""
pass
def post_duplicate(self, origin):
"""This method is called after finishing the duplication.
:type origin models.Model
:param origin the origin instance
"""
pass
```
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for django-modelduplication-0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 96e0ee9767745f336c5c1032af0959627396f70c97d877ae8ea1739407b583fd |
|
MD5 | efc9af73acb97076ffd2eee51cfb90e1 |
|
BLAKE2b-256 | 1274f65d567a2445312627e0798d422f27e94db6277f9c276e889da99cdb83a4 |