Opened 9 years ago

Closed 8 years ago

#1577 closed defect (duplicate)

Edit inline broken for models with multiple foreign keys to another model.

Reported by: k.kosciuszkiewicz at gmail dot com Owned by: adrian
Component: contrib.admin Version:
Severity: normal Keywords:
Cc: mir@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Test case:

class Publication(meta.Model):
    author = meta.CharField(maxlength=100)
    title = meta.CharField(maxlength=100)
    class META:
        admin = meta.Admin()

class Reference(meta.Model):
    position = meta.PositiveSmallIntegerField(core=True)
    cited    = meta.ForeignKey(Publication,
                    related_name="citation",
                    core=True)
    citing   = meta.ForeignKey(Publication,
                    related_name="reference",
                    edit_inline=meta.TABULAR)
    class META:
        admin = meta.Admin()
        ordering = ['position']

This should be perfectly valid but breaks in django/contrib/admin/templatetags/admin_modify.py in method EditInlineMode.render() with statement:

    klass = relation.field.rel.edit_inline

that returns False instead of class name. This is propagated further to result in attempt to call False(...) instead of ClassName(...) later in template rendering code.

Change History (2)

comment:1 Changed 9 years ago by mir@…

  • Cc mir@… added

comment:2 Changed 8 years ago by Gary Wilson <gary.wilson@…>

  • Resolution set to duplicate
  • Status changed from new to closed

Marking this a duplicate of #1939, as there is more discussion there and also some code.

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