* 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.
* 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>
* needs_docs: 1 => 0
* has_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/4027#comment:21>
* 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>
* 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>
* 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>
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>
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>