#4027: ability to make a copies of model instances
------------------------------------+---------------------------------------
          Reporter:  Marek Kubica   |         Owner:  nobody  
            Status:  new            |     Milestone:          
         Component:  Documentation  |       Version:  SVN     
        Resolution:                 |      Keywords:  db, copy
             Stage:  Accepted       |     Has_patch:  0       
        Needs_docs:  1              |   Needs_tests:  0       
Needs_better_patch:  0              |  
------------------------------------+---------------------------------------
Changes (by mtredinnick):

  * has_patch:  1 => 0
  * component:  Database layer (models, ORM) => Documentation
  * stage:  Design decision needed => Accepted

Comment:

 This is possible in a few lines of code for each model. You can copy many-
 to-many field by doing `new_instance.m2m = old_instance.m2m.all()`, for
 example. Ditto for foreign keys. This isn't always want you want when
 creating a copy of a model, however (think deep-copy versus shallow-copy),
 so really has to be left up to the individual case. For any particular
 model, a duplicate method is short enough already that Django doesn't need
 additions.

 *However*, a documentation patch to explain this little fragment would be
 useful. We should start capturing some of these little patterns.

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

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to