Opened 11 years ago

Closed 11 years ago

#5488 closed (fixed)

newforms-admin: inline fields with multiple fk's between models doesn't work

Reported by: jdetaeye Owned by: jdetaeye
Component: contrib.admin Version: newforms-admin
Severity: Keywords: newforms-admin: inline
Cc: jdetaeye@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


In case a single foreign key relation exists between the inline model and its parent, all is fine.
When there are multiple keys between the models, the InlineModelAdmin class provides the field fk_name in which we can define which one to use.

The required lookup when the fk_name is specified has not been coded yet: forgotten or skipped-for-now.
The attached patch provides the implementation.

Attachments (1)

newforms_admin_inline.patch (4.1 KB) - added by jdetaeye 11 years ago.
implementation patch

Download all attachments as: .zip

Change History (6)

Changed 11 years ago by jdetaeye

Attachment: newforms_admin_inline.patch added

implementation patch

comment:1 Changed 11 years ago by jdetaeye

The real changes in the patch are in lines 326-333 only.
Changes in other lines are trailing spaces removed by my source editor...

comment:2 Changed 11 years ago by Nicola Larosa

Do you really mean this does not need tests? :-) I'd like to supply them, otherwise (if I manage to discover what's the new syntax for inline fields).

Oh, and would you please add your email to the ticket? It would be nice to be able to contact you directly. Thanks.

comment:3 Changed 11 years ago by jdetaeye

Cc: jdetaeye@… added

if I manage to discover what's the new syntax for inline fields

I share your frustration.
Here's what I figured out:

class Child_Inline(admin.TabularInline):
  model = Child
  extra = 3

class Parent_admin(admin.ModelAdmin):
  inlines = [Child_Inline]

comment:4 Changed 11 years ago by jkocherhans

Triage Stage: UnreviewedAccepted

Marked #5358 as a duplicate.

comment:5 Changed 11 years ago by jkocherhans

Resolution: fixed
Status: newclosed

(In [6301]) newforms-admin: Fixed #5488. inlines with multiple ForeignKeys to the same parent don't work. Thanks jdetaeye. Also, some whitespace cleanup. Sorry for the mess.

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