Opened 16 years ago

Closed 15 years ago

#7631 closed (fixed)

Model backward inheritance in newforms admin

Reported by: occulkot@… Owned by: nobody
Component: contrib.admin Version: dev
Severity: Keywords:
Cc: mateusz@… Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

class Document(models.Model):
    num = models.CharField(max_length=30)

class DocumentType(Document):
    payment_type = models.IntegerField()
    payment_date = models.DateField()
    client = models.ForeignKey(Client)

class OtherDocument(Document):
    first_field = models.CharField(max_length=111)
    second_field = models.CharField(max_length=123)

class DocumentRow(models.Model)
    document = models.ForeignKey(Document, related_name='rows')
    kind = models.CharField(max_length=30)
    date = models.DateField()

As you can see we have 2 kinds of documents - DocumentType and OtherDocument - every kind of document has same fields as "Document" and aditional fields. And every kind of document should hav rows.
It works perfectly in standard views but its problematic to implement in admin.
i tried

class DocumentRowAdmin(admin.TabularInline):
    extra = 10
    model = models.DocumentRow
    
class DocumentTypeAdmin(admin.ModelAdmin):
    inlines = [DocumentRowAdmin, ]

admin.register(models.DocumentType, PrzesuniecieAdmin)
admin.register(models.OtherDocument, PrzesuniecieAdmin)

And this way it only raises an exception about relationship.
Maybe some "inline_for_parent" option or sth?
im trying to make it working myself but im stuck in BaseModelFormSet.get_queryset method

Change History (5)

comment:1 by munhitsu, 16 years ago

Cc: mateusz@… added

comment:2 by Eric Holscher, 16 years ago

milestone: post-1.0
Triage Stage: UnreviewedDesign decision needed
Version: newforms-adminSVN

comment:3 by Piotr Lewandowski <django@…>, 16 years ago

Component: UncategorizedAdmin interface

comment:4 by (none), 15 years ago

milestone: post-1.0

Milestone post-1.0 deleted

comment:5 by jkocherhans, 15 years ago

Resolution: fixed
Status: newclosed

There are some typos in these models, but I did my best to re-create them, and they work with django trunk as of r10283. Please re-open with more details if this isn't fixed.

Note: See TracTickets for help on using tickets.
Back to Top