Opened 5 years ago

Closed 5 years ago

Last modified 3 years ago

#12569 closed (duplicate)

GenericInlineModelAdmin's get_formset method has a non standard signature

Reported by: specialunderwear Owned by: nobody
Component: Uncategorized Version: 1.2-alpha
Severity: Keywords: inline get_formset defaults kwargs
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Unlike InlineModelAdmin GenericInlineModelAdmin does not let you override any values using keyword arguments.

InlineModelAdmin's signature looks like this:

def get_formset(self, request, obj=None, **kwargs):

Any keyword arguments passed will override settings in the defaults dict which is constructed inside the function.
This mechanic makes overriding the method while still using some of the standard functionality inside get_formset very streamlined.

If the same is tried with GenericInlineModelAdmin you will have to copy paste the whole function body because this the signature of it's get_formset method:

def get_formset(self, request, obj=None):

The defaults object constructed inside the method can not be overriden by passing keyword arguments, meaning you can not reuse any of the functionality in the method when overriding it, using inheritance.

Solution:

Make GenericInlineModelAdmin use the same mechanic as InlineModelAdmin so you can override the defaults object using keyword arguments.

See against current trunk.

Attachments (1)

genericinlinemodeladmin_get_formset_kwargs_fix.diff (811 bytes) - added by specialunderwear 5 years ago.

Download all attachments as: .zip

Change History (3)

Changed 5 years ago by specialunderwear

comment:1 Changed 5 years ago by brosner

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #9588

comment:2 Changed 3 years ago by jacob

  • milestone 1.2 deleted

Milestone 1.2 deleted

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