Changes between Initial Version and Version 3 of Ticket #7918


Ignore:
Timestamp:
Jul 23, 2008, 11:50:51 AM (16 years ago)
Author:
Brian Rosner
Comment:

Fixed ticket description formatting.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #7918

    • Property Patch needs improvement set
    • Property Needs documentation set
    • Property Needs tests set
  • Ticket #7918 – Description

    initial v3  
    11At the moment, if you have a hierarchy:
    22
     3{{{
    34class Place(models.Model):
    45    name = models.CharField(max_length=50)
     
    89    serves_hot_dogs = models.BooleanField()
    910    serves_pizza = models.BooleanField()
     11}}}
    1012
    1113(as per http://www.djangoproject.com/documentation/model-api/#multi-table-inheritance), it doesn't interact all that well with inlined ForeignKeyed models. Imagine you had:
    1214
     15{{{
    1316class Owner:
    1417    name = models.CharField(max_length=100)
    1518    place = models.ForeignKey(Place)
     19}}}
    1620
    1721(so a Place can have multiple Owners). This also works fine with Restaurants, because every Restaurant ''is-a'' Place. However, if you want to inline the Owners:
    1822
     23{{{
    1924class OwnerInline(admin.TabularInline):
    2025    model = Owner
     
    2429    model = Place
    2530    inlines = [OwnerInline]
     31}}}
    2632
    2733then this won't work; if you try and create a Restaurant, you get a complaint that Owner has no ForeignKey to Restaurant (because technically it doesn't). This is because (new)forms._get_foreign_key checks that the ForeignKey points to this model itself, where it should really be checking whether the ForeignKey points to this model ''or any of its ancestor classes''. The attached patch rectifies this.
    28 
Back to Top