Django

Code

Ticket #5488 (closed: fixed)

Opened 1 year ago

Last modified 1 year ago

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

Reported by: jdetaeye Assigned to: jdetaeye
Milestone: Component: django.contrib.admin
Version: newforms-admin Keywords: newforms-admin: inline
Cc: jdetaeye@frepple.com Triage Stage: Accepted
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

newforms_admin_inline.patch (4.1 kB) - added by jdetaeye on 09/15/07 03:39:23.
implementation patch

Change History

09/15/07 03:39:23 changed by jdetaeye

  • attachment newforms_admin_inline.patch added.

implementation patch

09/15/07 03:43:04 changed by jdetaeye

  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

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

09/15/07 05:09:15 changed 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.

09/15/07 06:31:12 changed by jdetaeye

  • cc set to jdetaeye@frepple.com.

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]

09/15/07 12:53:22 changed by jkocherhans

  • stage changed from Unreviewed to Accepted.

Marked #5358 as a duplicate.

09/15/07 13:13:50 changed by jkocherhans

  • status changed from new to closed.
  • resolution set to fixed.

(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/Change #5488 (newforms-admin: inline fields with multiple fk's between models doesn't work)




Change Properties
Action