Skip to main content

django-modelclone-next

Allows users to duplicate a model in admin.

This is a fork of https://github.com/RealGeeks/django-modelclone

Installation

$ pip install django-modelclone-next

then:

  1. Add 'modelclone' to INSTALLED_APPS
  2. In your admin.py files extend from modelclone.ClonableModelAdmin instead of Django's ModelAdmin

The models that have admin configuration extending modelclone.ClonableModelAdmin will have a new link on the Change page to duplicate that object

Screenshot Duplicate link

This links redirects to a page similar to an Add page but with all the fields already filled with the values from the original object.

Note that you still need to save to get a new object. And make sure to edit fields that must be unique otherwise you will get a validation error.

But Django already has a 'save as'

Yes, I know. Django Admin has a save_as feature that adds a new button to your Change page to save a new instance of that object.

I don't like the way this feature works because you will save an identical copy of the original object (if you don't get validation errors) as soon as you click that link, and if you forget to make the small changes that you wanted in the new object you will end up with a duplicate of the existing object.

On the other hand, django-modelclone offers an intermediate view, that basically pre-fills the form for you. So you can modify and then save a new instance. Or just go away without side effects.

Requirements

  • Python 3
  • Django 2.2, 3.0, 3.1, 3.2 or 4.0

See tox.ini

Hacking

Fork the repository on github, make your changes (don't forget the tests) and send a pull request.

To run the tests, install and run Tox:

$ pip install tox
$ tox

You can also run the sample project to test manually. In this case you'll need to install Django, or just use one of the virtualenvs tox creates, for example:

$ source .tox/py310-django32/bin/activate

then start the server

(py310-django32) $ ./manager serve

The app is available on http://localhost:8000/admin/, username and password "admin".

Metadata

Release files for django-modelclone-next 0.8.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-modelclone-next 0.8.2
File Size Uploaded
django-modelclone-next-0.8.2.tar.gz 6.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-modelclone-next 0.8.2
File Interpreter ABI Platform
django_modelclone_next-0.8.2-py3-none-any.whl Python 3 none any Details

Total release size: 14.5 kB

Release files / django-modelclone-next-0.8.2.tar.gz

Download URL django-modelclone-next-0.8.2.tar.gz
Size 6.9 kB
Tags Source
SHA-256 checksum
How to use checksums
26f88b6c8d36eed4b86ba3f33ef85073b8ba072fe15d5af245e2b0803020d5a4
BLAKE2b-256 checksum
How to use checksums
7a1063475d97c0a53de56ce4492c9d8d2e3b2d53eba64ad63e281ae28f50d433
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.9

Release files / django_modelclone_next-0.8.2-py3-none-any.whl

Download URL django_modelclone_next-0.8.2-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1f834ba84e4be501011f5d110581893be2a2c1748f7defcd8f54fedcd1843b04
BLAKE2b-256 checksum
How to use checksums
ba302378c89e2614d53baab15647a5e3e1e6098b0df48fd1f5ff4dfea6a34393
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.9

Release history Release notifications | RSS feed

This release

0.8.2 This release

2 release files

0.8.1

2 release files

0.8.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page