#11097: Formset documentation should include a note about form.blah_ptr for 
derived
models
---------------------------+------------------------------------------------
 Reporter:  drozzy         |       Owner:  nobody    
   Status:  new            |   Milestone:            
Component:  Documentation  |     Version:  1.0       
 Keywords:                 |       Stage:  Unreviewed
Has_patch:  0              |  
---------------------------+------------------------------------------------
 Whenever a model inherits from a non-abstract model, it shares it's
 primary key with it.
 As a consequence, the form produced by inlineformset_factory no longer has
 id field, by the "parentname_ptr" field.

 For example imagine you have a case such as:


 {{{
 class Car(models.Model):
     color = #string field

 class BMW(Car):
     shop = models.ForeignKey(CarShop)
 }}}


 Then in our view:


 {{{
 car = BMW.objects.get(pk=1)
 BMWFromset = inlineformset_factory(CarShop, BMW,
                                 can_delete=True,
                                 extra=1)
 formset = BMWFormset(instance=car)
 }}}


 The in our html:

 {{{
 <form method="post">
 {{formset.management_form}}
 <ul>
         {% for form in formset.forms %}

         <li>
         <!-- NOTICE that we do NOT use form.id here -->
         {{form.car_ptr}}
         {{form}}
         </li>

         {% endfor %}
 </ul>
 <input type="submit"  value="submit" />
 </form>
 }}}

-- 
Ticket URL: <http://code.djangoproject.com/ticket/11097>
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 django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to