Code

Opened 8 years ago

Closed 7 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.

Attachments (0)

Change History (2)

comment:1 Changed 8 years ago by mir@…

  • Cc mir@… added

comment:2 Changed 7 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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.