Skip to main content

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.

.. image:: https://coveralls.io/repos/github/squallcs12/django-modelduplication/badge.svg?branch=master
:target: https://coveralls.io/github/squallcs12/django-modelduplication?branch=master


Quick start
-----------

1. Add "modelduplication" to your INSTALLED_APPS setting like this:

.. code-block:: python

INSTALLED_APPS = [
# ...
'modelduplication',
]


2. Define `pre_duplicate` and `post_duplicate` to your models to customize duplication process:

.. code-block:: python

class Book(models.Model):
def pre_duplicate(self, origin, first_level):
"""This method use to modify object before `save` on duplication.
:type origin models.Model
:type first_level bool
:param first_level is the root level of duplication
: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

django-modelduplication-0.1.4.tar.gz (2.9 kB view details)

Uploaded Source

File details

Details for the file django-modelduplication-0.1.4.tar.gz.

File metadata

File hashes

Hashes for django-modelduplication-0.1.4.tar.gz
Algorithm Hash digest
SHA256 710904a493d3d0b31d744c02c00e60c587c9e9e510f6c90c07b13d1283eb1d99
MD5 3063ba05806e3dee8c1effd0fa251ca6
BLAKE2b-256 0de324cc2f4f6ed8673345802f0fcc59bce24fa7bd32b2e53b6dc8e5445399e5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page