Re: [Django] #4027: Document how to make copies of model instances

10 views
Skip to first unread message

Django

unread,
Jun 9, 2011, 7:59:01 AM6/9/11
to django-...@googlegroups.com
#4027: Document how to make copies of model instances
----------------------------------------+-------------------------------
Reporter: Marek Kubica | Owner: oinopion
Type: New feature | Status: new
Milestone: | Component: Documentation
Version: SVN | Severity: Normal
Resolution: | Keywords: db, copy
Triage Stage: Accepted | Has patch: 0
Needs documentation: 1 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
----------------------------------------+-------------------------------
Changes (by oinopion):

* owner: nobody => oinopion
* ui_ux: => 0
* easy: => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/4027#comment:19>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jun 9, 2011, 9:38:48 AM6/9/11
to django-...@googlegroups.com
#4027: Document how to make copies of model instances
----------------------------------------+-------------------------------
Reporter: Marek Kubica | Owner: oinopion
Type: New feature | Status: assigned
Milestone: | Component: Documentation
Version: SVN | Severity: Normal
Resolution: | Keywords: db, copy
Triage Stage: Accepted | Has patch: 0
Needs documentation: 1 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
----------------------------------------+-------------------------------
Changes (by oinopion):

* status: new => assigned
* cc: tomek+django@… (added)


Comment:

I've written short section on copying model instances. I surely need some
help with people that know how to write.

--
Ticket URL: <https://code.djangoproject.com/ticket/4027#comment:20>

Django

unread,
Jun 9, 2011, 9:44:40 AM6/9/11
to django-...@googlegroups.com
#4027: Document how to make copies of model instances
----------------------------------------+-------------------------------
Reporter: Marek Kubica | Owner: oinopion
Type: New feature | Status: assigned
Milestone: | Component: Documentation
Version: SVN | Severity: Normal
Resolution: | Keywords: db, copy
Triage Stage: Accepted | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
----------------------------------------+-------------------------------
Changes (by oinopion):

* needs_docs: 1 => 0
* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/4027#comment:21>

Django

unread,
Jun 9, 2011, 10:19:11 AM6/9/11
to django-...@googlegroups.com
#4027: Document how to make copies of model instances
-------------------------------------+-------------------------------------
Reporter: Marek | Owner: oinopion
Kubica | Status: assigned
Type: New | Component: Documentation
feature | Severity: Normal
Milestone: | Keywords: db, copy
Version: SVN | Has patch: 1
Resolution: | Needs tests: 0
Triage Stage: Ready for | Easy pickings: 0
checkin |
Needs documentation: 0 |
Patch needs improvement: 0 |
UI/UX: 0 |
-------------------------------------+-------------------------------------
Changes (by erikr):

* stage: Accepted => Ready for checkin


Comment:

I've made a few tiny language improvements. Otherwise, it looks good to
me, with clear and simple examples. RFCed.

--
Ticket URL: <https://code.djangoproject.com/ticket/4027#comment:22>

Django

unread,
Sep 9, 2011, 4:32:34 PM9/9/11
to django-...@googlegroups.com
#4027: Document how to make copies of model instances
-------------------------------------+-------------------------------------
Reporter: Marek | Owner: oinopion
Kubica | Status: assigned
Type: New | Component: Documentation
feature | Severity: Normal
Milestone: | Keywords: db, copy
Version: SVN | Has patch: 1
Resolution: | Needs tests: 0
Triage Stage: Ready for | Easy pickings: 0
checkin |
Needs documentation: 0 |
Patch needs improvement: 0 |
UI/UX: 0 |
-------------------------------------+-------------------------------------
Changes (by bruth):

* cc: bruth@… (added)


Comment:

I tackled this problem as a separate app: https://github.com/cbmi/django-
forkit. It is simply an abstract model that implements a few methods such
as `fork`, `reset`, and `diff`. It handles all three relationship types,
though there are a few known issues (e.g. M2M through models are not yet
supported). Deep `diff`ing is not yet fully baked, and the `reset` method
must propagate that a `reset` is intended for all related objects (rather
than creating new ones). Saving related objects are deferred until the
whole hierarchy has been traversed to ensure data integrity (and provides
ways of altering the objects post `fork`/`reset`).

Here are the tests for it thus far: https://github.com/cbmi/django-
forkit/blob/master/forkit/tests/models.py. I would be interested in
hearing feedback on a few of the assumptions I made (e.g. which
relationships to choose for a shallow copy). And definitely send a pull
request or submit a ticket if there are more elegant ways to make use of
the Django model internals.

I am posting here only to make others aware of it, but I don't think it is
appropriate to go into Django proper.

--
Ticket URL: <https://code.djangoproject.com/ticket/4027#comment:23>

Django

unread,
Nov 1, 2011, 5:44:19 PM11/1/11
to django-...@googlegroups.com
#4027: Document how to make copies of model instances
-------------------------------------+-------------------------------------
Reporter: Marek Kubica | Owner: oinopion
Type: New feature | Status: closed
Component: Documentation | Version: SVN
Severity: Normal | Resolution: fixed
Keywords: db, copy | Triage Stage: Ready for
Has patch: 1 | checkin
Needs tests: 0 | Needs documentation: 0
Easy pickings: 0 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by lukeplant):

* status: assigned => closed
* resolution: => fixed


Comment:

In [17064]:
{{{
#!CommitTicketReference repository="" revision="17064"
Fixed #4027 - Document how to make copies of model instances

Thanks to Marek Kubica for the report and initial patch, and to oinopion
and
erikr for work on the patch.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/4027#comment:24>

Django

unread,
Feb 22, 2021, 5:53:03 AM2/22/21
to django-...@googlegroups.com
#4027: Document how to make copies of model instances
-------------------------------------+-------------------------------------
Reporter: Marek Kubica | Owner: Tomek
| Paczkowski

Type: New feature | Status: closed
Component: Documentation | Version: master

Severity: Normal | Resolution: fixed
Keywords: db, copy | Triage Stage: Ready for
| checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"0fd05df7b5690fb1b675e1b4d9c92bb22ff74360" 0fd05df]:
{{{
#!CommitTicketReference repository=""
revision="0fd05df7b5690fb1b675e1b4d9c92bb22ff74360"
Refs #4027 -- Added Model._state.adding to docs about copying model
instances.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/4027#comment:25>

Django

unread,
Feb 22, 2021, 5:53:30 AM2/22/21
to django-...@googlegroups.com
#4027: Document how to make copies of model instances
-------------------------------------+-------------------------------------
Reporter: Marek Kubica | Owner: Tomek
| Paczkowski
Type: New feature | Status: closed
Component: Documentation | Version: master
Severity: Normal | Resolution: fixed
Keywords: db, copy | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"cf05f9f205e2dcbcaad10b24be94ad66c0523514" cf05f9f2]:
{{{
#!CommitTicketReference repository=""
revision="cf05f9f205e2dcbcaad10b24be94ad66c0523514"
[3.2.x] Refs #4027 -- Added Model._state.adding to docs about copying
model instances.

Backport of 0fd05df7b5690fb1b675e1b4d9c92bb22ff74360 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/4027#comment:26>

Reply all
Reply to author
Forward
0 new messages