#7623: Multi-table inheritance does not allow linking new instance of child 
model
to existing parent model instance.
----------------------------------------------+-----------------------------
          Reporter:  [EMAIL PROTECTED]  |         Owner:  nobody                
                    
            Status:  new                      |     Milestone:                  
                          
         Component:  Core framework           |       Version:  SVN             
                          
        Resolution:                           |      Keywords:  
model-inheritance, multi-table-inheritance
             Stage:  Unreviewed               |     Has_patch:  0               
                          
        Needs_docs:  0                        |   Needs_tests:  0               
                          
Needs_better_patch:  0                        |  
----------------------------------------------+-----------------------------
Changes (by korpios):

  * needs_better_patch:  => 0
  * needs_tests:  => 0
  * needs_docs:  => 0

Comment:

 I have a Bazaar branch available that solves this issue:

 https://code.launchpad.net/~theonion/django/makechild

 In short, it adds a couple of new methods to `QuerySet` / `Manager`:
 `prepare_child()` and `create_child()`.  For an existing `Place` `p` that
 isn't currently a `Restaurant`, you could do either of the following:
 {{{
 # p is an existing Place
 r = Restaurant.objects.prepare_child(p)
 r.cusine = "Sushi"
 r.rating = 5
 r.save()

 # or, alternately
 r = Restaurant.objects.create_child(p, cusine="Sushi", rating=5)
 }}}

 While `create_child()` saves to the database, `prepare_child()` does not;
 the latter allows you to further alter the instance before saving.

 I tried several alternate routes — supporting setting children directly
 from parents, supporting setting parents directly from children, a single
 unified `child()` method — and none worked cleanly.  The unified `child()`
 method presented the issue of passing a `save` flag; there was no way to
 avoid a collision with a field named `save` in the keyword arguments.

 I'll add an initial patch here based on the Bazaar repository for now; I
 still need to add tests.  Any patches here will lag behind the Bazaar
 repository, as the latter is where my actual development takes place.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/7623#comment:1>
Django Code <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