{"id":16550602,"url":"https://github.com/agusmakmun/django-object-cloner","last_synced_at":"2026-05-11T09:53:41.563Z","repository":{"id":68987853,"uuid":"261041445","full_name":"agusmakmun/django-object-cloner","owner":"agusmakmun","description":":clipboard: Easy way to clone/duplicate the objects including their child's with recursively.","archived":false,"fork":false,"pushed_at":"2020-05-12T08:19:00.000Z","size":12,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-04T15:35:35.994Z","etag":null,"topics":["django","django-cloner","django-models","django-object-cloner"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/agusmakmun.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-03T23:36:52.000Z","updated_at":"2024-01-19T10:27:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"b3c1cb13-5fe9-4102-b520-2efe73e7f473","html_url":"https://github.com/agusmakmun/django-object-cloner","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/agusmakmun/django-object-cloner","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agusmakmun%2Fdjango-object-cloner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agusmakmun%2Fdjango-object-cloner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agusmakmun%2Fdjango-object-cloner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agusmakmun%2Fdjango-object-cloner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/agusmakmun","download_url":"https://codeload.github.com/agusmakmun/django-object-cloner/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agusmakmun%2Fdjango-object-cloner/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32889971,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-10T13:40:02.631Z","status":"online","status_checked_at":"2026-05-11T02:00:05.975Z","response_time":120,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["django","django-cloner","django-models","django-object-cloner"],"created_at":"2024-10-11T19:34:57.185Z","updated_at":"2026-05-11T09:53:41.531Z","avatar_url":"https://github.com/agusmakmun.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"django-object-cloner\n====================\n\nEasy way to clone/duplicate the objects including their child's with recursively.\n\n\n    For real case in e-commerce system like amazon, e-bay, etc. When you become a seller and you have the products to sale,\n    one of the feature in seller admin such is \"duplicate product/copy product/clone product\"\n    to make the seller easy clone/duplicate the similar product without uploading again.\n\n\nStrategy\n-----------------\n\n1. ``def clone_object(obj, attrs={})`` starts by build a \"flat\" clone of the given \"obj\"\n2. M2M fields are managed by replicating all related records found on parent \"obj\" into \"clone\"\n3. for 1-1 and 1-N relations, we clone all child objects by calling recursively ``clone_object()``, but overridding the remote field with the new cloned object\n\n::\n\n    \u003e\u003e\u003e from object_cloner.utils import clone_object\n    \u003e\u003e\u003e from app.models import Product\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e product = Product.objects.first()\n    \u003e\u003e\u003e product.pk\n    1\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e cloned_product = clone_object(product)\n    \u003e\u003e\u003e cloned_product.pk\n    2\n    \u003e\u003e\u003e\n\n\n\nProudly thanks to @morlandi who solved this problem (https://stackoverflow.com/a/61729857/6396981)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagusmakmun%2Fdjango-object-cloner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fagusmakmun%2Fdjango-object-cloner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagusmakmun%2Fdjango-object-cloner/lists"}