Code

Opened 7 years ago

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

Description

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 7 years ago.
implementation patch

Download all attachments as: .zip

Change History (6)

Changed 7 years ago by jdetaeye

implementation patch

comment:1 Changed 7 years ago by jdetaeye

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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 7 years ago by tekNico

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 7 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 7 years ago by jkocherhans

  • Triage Stage changed from Unreviewed to Accepted

Marked #5358 as a duplicate.

comment:5 Changed 7 years ago by jkocherhans

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

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

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.