{ "info": { "author": "David Danier", "author_email": "david.danier@team23.de", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Framework :: Django", "Framework :: Django :: 1.8", "Framework :: Django :: 1.9", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Natural Language :: English", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.5" ], "description": "django-cloneable\n================\n\n|pypi-badge| |build-status|\n\n.. |build-status| image:: https://travis-ci.org/team23/django_cloneable.svg\n :target: https://travis-ci.org/team23/django_cloneable\n\n.. |pypi-badge| image:: https://img.shields.io/pypi/v/django-cloneable.svg\n :target: https://pypi.python.org/pypi/django-cloneable\n\n**django-cloneable** provides a ``CloneableMixin`` class that has a ``clone()``\nmethod. It can be mixed into any Django model.\n\nThe ``clone()`` method must be called on an already saved instance (one that\nhas ``pk`` set). It then returns a new instance of the model that has all the\nsame field values as the original instance, but it will be a seperate database\nrow with a distinct primary key.\n\nAn example:\n\n.. code:: python\n\n from django.db import models\n from django_cloneable import CloneableMixin\n\n class Ingredient(CloneableMixin, models.Model):\n name = models.CharField(max_length=50)\n is_spicy = models.BooleanField(default=False)\n\n class Pizza(CloneableMixin, models.Model):\n name = models.CharField(max_length=50)\n price = models.IntegerField()\n ingredients = models.ManyToManyField(Ingredient)\n\n tomatos = Ingredient.objects.create(name='Tomato', is_spicy=False)\n cheese = Ingredient.objects.create(name='Cheese', is_spicy=False)\n chili = Ingredient.objects.create(name='Chili', is_spicy=True)\n\n margarita = Pizza.objects.create(name='Margarita')\n margarita.ingredients.add(tomatos)\n margarita.ingredients.add(cheese)\n\n diabolo = margarita.clone(attrs={'name': 'Diabolo'})\n diabolo.ingerdients.add(chili)\n\n # Nothing has changed on the original instance.\n assert margarita.name == 'Margarita'\n assert margarita.ingredients.all() == [tomatos, cheese]\n\n # The original m2m values were copied, and the new values were added.\n assert diabolo.name == 'Diabolo'\n assert diabolo.ingredients.all() == [tomatos, cheese, chili]\n\nAs shown in the example, you can provide the ``attrs`` that shall be replaced\nin the cloned object. That lets you change the cloned instance before it gets\nsaved. By default the clone will be saved to the database, so that it has\n``pk`` when it gets returned.\n\nThere are numerous hooks on how you can modify the cloning logic. The best way\nto learn about them is to have a look at the implementation of\n``CloneableMixin``.\n\nDevelopment\n-----------\n\nInstall the dependencies (including the test dependencies) with::\n\n pip install -r requirements.txt\n\nThen you can run all tests with::\n\n tox\n\n\nChangelog\n=========\n\n0.1.0\n-----\n\n- Initial release.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/team23/django_cloneable", "keywords": null, "license": "BSD licence, see LICENSE file", "maintainer": null, "maintainer_email": null, "name": "django-cloneable", "package_url": "https://pypi.org/project/django-cloneable/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-cloneable/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/team23/django_cloneable" }, "release_url": "https://pypi.org/project/django-cloneable/0.1.0/", "requires_dist": null, "requires_python": null, "summary": "Let's you clone a Django model instance including many to many fields", "version": "0.1.0" }, "last_serial": 4304482, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "97cbdb908bfc46b8d6a7925515a8aa21", "sha256": "23a5e56d27503c06b59b60df39465ab0426eadff96ffb6d20ae910373bef156e" }, "downloads": -1, "filename": "django-cloneable-0.1.0.tar.gz", "has_sig": false, "md5_digest": "97cbdb908bfc46b8d6a7925515a8aa21", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7033, "upload_time": "2016-04-05T08:35:01", "url": "https://files.pythonhosted.org/packages/dd/06/ec96c0e5c5ead72a052a5c3b72a40e6d4a835d17af086e39de0286123c50/django-cloneable-0.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "97cbdb908bfc46b8d6a7925515a8aa21", "sha256": "23a5e56d27503c06b59b60df39465ab0426eadff96ffb6d20ae910373bef156e" }, "downloads": -1, "filename": "django-cloneable-0.1.0.tar.gz", "has_sig": false, "md5_digest": "97cbdb908bfc46b8d6a7925515a8aa21", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7033, "upload_time": "2016-04-05T08:35:01", "url": "https://files.pythonhosted.org/packages/dd/06/ec96c0e5c5ead72a052a5c3b72a40e6d4a835d17af086e39de0286123c50/django-cloneable-0.1.0.tar.gz" } ] }