[Django] #18388: problematic code in InlineModelAdmin

19 views
Skip to first unread message

Django

unread,
May 27, 2012, 3:33:48 AM5/27/12
to django-...@googlegroups.com
#18388: problematic code in InlineModelAdmin
-------------------------------+--------------------
Reporter: d.willy.c.c@… | Owner: nobody
Type: New feature | Status: new
Component: contrib.admin | Version: 1.4
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
in class InlineModelAdmin and def get_formset in line 1401
defaults = {
"form": self.form,
"formset": self.formset,
"fk_name": self.fk_name,
"fields": fields,
"exclude": exclude,
"formfield_callback": partial(self.formfield_for_dbfield,
request=request),
"extra": self.extra,
"max_num": self.max_num,
"can_delete": can_delete,
}
I think that is more customizable code should be as follows
"form": self.form,
"formset": self.formset,
"fk_name": self.fk_name,
"fields": fields,
"exclude": exclude,
"formfield_callback": partial(self.formfield_for_dbfield,
request=request),
"extra": '''self.get_extra()''',
"max_num": '''self.get_max_num()''',
"can_delete": can_delete,

--
Ticket URL: <https://code.djangoproject.com/ticket/18388>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 27, 2012, 2:20:52 PM5/27/12
to django-...@googlegroups.com
#18388: Add more hooks in the ModelAdmin (get_extra, get_max_num)
-------------------------------+------------------------------------
Reporter: d.willy.c.c@… | Owner: nobody
Type: New feature | Status: new
Component: contrib.admin | Version: 1.4
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by rasca):

* needs_better_patch: => 0
* needs_tests: => 0
* easy: 0 => 1
* needs_docs: => 0
* stage: Unreviewed => Accepted


Comment:

This is in tone with #17646, #17006 and #16841.

I'm accepting this based on that they are similar to the other ones,
adding hooks to the ModelAdmin.

Maybe we can think a way to add this "hooks" in a more DRY way than adding
a function get_FOO(self, request): return self.FOO

--
Ticket URL: <https://code.djangoproject.com/ticket/18388#comment:1>

Django

unread,
May 27, 2012, 11:59:01 PM5/27/12
to django-...@googlegroups.com
#18388: Add more hooks in the ModelAdmin (get_extra, get_max_num)
-------------------------------+------------------------------------
Reporter: d.willy.c.c@… | Owner: nobody
Type: New feature | Status: new
Component: contrib.admin | Version: 1.4
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------

Comment (by anonymous):

I think 'GET' is the easiest way to personalize this, and also believe
that all variables should have a 'GET'

--
Ticket URL: <https://code.djangoproject.com/ticket/18388#comment:2>

Django

unread,
Jun 19, 2012, 7:31:01 PM6/19/12
to django-...@googlegroups.com
#18388: Add more hooks in the ModelAdmin (get_extra, get_max_num)
-------------------------------+-------------------------------------
Reporter: d.willy.c.c@… | Owner: anonymous
Type: New feature | Status: new
Component: contrib.admin | Version: 1.4
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+-------------------------------------
Changes (by vane.gomesl@…):

* owner: nobody => anonymous


--
Ticket URL: <https://code.djangoproject.com/ticket/18388#comment:3>

Django

unread,
Jun 19, 2012, 7:33:09 PM6/19/12
to django-...@googlegroups.com
#18388: Add more hooks in the ModelAdmin (get_extra, get_max_num)
-------------------------------+----------------------------------------
Reporter: d.willy.c.c@… | Owner: vanessagomes
Type: New feature | Status: new
Component: contrib.admin | Version: 1.4
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+----------------------------------------
Changes (by vanessagomes):

* owner: anonymous => vanessagomes


--
Ticket URL: <https://code.djangoproject.com/ticket/18388#comment:4>

Django

unread,
Jun 19, 2012, 7:36:16 PM6/19/12
to django-...@googlegroups.com
#18388: Add more hooks in the ModelAdmin (get_extra, get_max_num)
-------------------------------+------------------------------------
Reporter: d.willy.c.c@… | Owner: nobody
Type: New feature | Status: new
Component: contrib.admin | Version: 1.4
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by vanessagomes):

* owner: vanessagomes => nobody


--
Ticket URL: <https://code.djangoproject.com/ticket/18388#comment:5>

Django

unread,
Nov 4, 2012, 3:31:17 PM11/4/12
to django-...@googlegroups.com
#18388: Add more hooks in the ModelAdmin (get_extra, get_max_num)
-------------------------------+------------------------------------
Reporter: d.willy.c.c@… | Owner: Melevir
Type: New feature | Status: assigned
Component: contrib.admin | Version: 1.4

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by Melevir):

* owner: nobody => Melevir
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/18388#comment:6>

Django

unread,
Nov 4, 2012, 4:03:24 PM11/4/12
to django-...@googlegroups.com
#18388: Add more hooks in the ModelAdmin (get_extra, get_max_num)
-------------------------------+------------------------------------
Reporter: d.willy.c.c@… | Owner: Melevir
Type: New feature | Status: assigned
Component: contrib.admin | Version: 1.4

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by Melevir):

* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/18388#comment:7>

Django

unread,
Nov 4, 2012, 4:06:16 PM11/4/12
to django-...@googlegroups.com
#18388: Add more hooks in the ModelAdmin (get_extra, get_max_num)
-------------------------------+------------------------------------
Reporter: d.willy.c.c@… | Owner: Melevir
Type: New feature | Status: assigned
Component: contrib.admin | Version: 1.4

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by Melevir):

* has_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/18388#comment:8>

Django

unread,
Nov 4, 2012, 4:13:12 PM11/4/12
to django-...@googlegroups.com
#18388: Add more hooks in the ModelAdmin (get_extra, get_max_num)
-------------------------------+------------------------------------
Reporter: d.willy.c.c@… | Owner: Melevir
Type: New feature | Status: assigned
Component: contrib.admin | Version: 1.4

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by Melevir):

* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/18388#comment:9>

Django

unread,
Feb 25, 2013, 9:20:43 PM2/25/13
to django-...@googlegroups.com
#18388: Add more hooks in the ModelAdmin (get_extra, get_max_num)
-------------------------------+------------------------------------
Reporter: d.willy.c.c@… | Owner: Melevir
Type: New feature | Status: assigned
Component: contrib.admin | Version: 1.4

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------

Comment (by javimansilla):

#19425 is proposing something similar and IMHO it's doing it on a better
way

--
Ticket URL: <https://code.djangoproject.com/ticket/18388#comment:10>

Django

unread,
May 19, 2013, 7:02:20 AM5/19/13
to django-...@googlegroups.com
#18388: Add more hooks in the ModelAdmin (get_extra, get_max_num)
-------------------------------+------------------------------------
Reporter: d.willy.c.c@… | Owner: Melevir
Type: New feature | Status: assigned
Component: contrib.admin | Version: 1.4

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------

Comment (by areski):

I agree also that #19425 is more elegant, I rebased the patch from that
ticket and added max_num as per the suggestion here.
See patch in attachment and the PR :
https://github.com/django/django/pull/1155

--
Ticket URL: <https://code.djangoproject.com/ticket/18388#comment:11>

Django

unread,
May 19, 2013, 9:33:56 AM5/19/13
to django-...@googlegroups.com
#18388: Add more hooks in the ModelAdmin (get_extra, get_max_num)
-------------------------------+------------------------------------
Reporter: d.willy.c.c@… | Owner: Melevir
Type: New feature | Status: assigned
Component: contrib.admin | Version: 1.4

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by areski):

* cc: areski@… (added)


Comment:

Just updated the patch to add some documentation

--
Ticket URL: <https://code.djangoproject.com/ticket/18388#comment:12>

Django

unread,
May 31, 2013, 4:25:23 PM5/31/13
to django-...@googlegroups.com
#18388: Add more hooks in the ModelAdmin (get_extra, get_max_num)
-------------------------------+------------------------------------
Reporter: d.willy.c.c@… | Owner: timo

Type: New feature | Status: assigned
Component: contrib.admin | Version: 1.4

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by timo):

* owner: Melevir => timo


Comment:

`InlineModelAdmin.get_extra` was added in #19425. I'll try to review and
commit the second half of this.

--
Ticket URL: <https://code.djangoproject.com/ticket/18388#comment:13>

Django

unread,
Jun 1, 2013, 6:21:23 PM6/1/13
to django-...@googlegroups.com
#18388: Add more hooks in the ModelAdmin (get_extra, get_max_num)
-------------------------------+------------------------------------
Reporter: d.willy.c.c@… | Owner: timo
Type: New feature | Status: closed
Component: contrib.admin | Version: 1.4
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"61524b09cfa3b51643d0e79cbf0e1e08ede357ae"]:
{{{
#!CommitTicketReference repository=""
revision="61524b09cfa3b51643d0e79cbf0e1e08ede357ae"
Fixed #18388 - Added InlineModelAdmin.get_max_num hook.

Thanks d.willy.c.c@ for the suggestion and Melevir and Areski Belaid for
work
on the patch.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/18388#comment:14>

Reply all
Reply to author
Forward
0 new messages