diff options
| author | Tim Graham <timograham@gmail.com> | 2013-06-01 18:16:57 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2013-06-01 18:20:54 -0400 |
| commit | 61524b09cfa3b51643d0e79cbf0e1e08ede357ae (patch) | |
| tree | 20dcdebd8369c70d0d5a94d1b62dd06101176e08 /django | |
| parent | 07a73a2714a504ae487112c1679977fccc19b159 (diff) | |
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.
Diffstat (limited to 'django')
| -rw-r--r-- | django/contrib/admin/options.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py index 97f82cbb59..34583ebf74 100644 --- a/django/contrib/admin/options.py +++ b/django/contrib/admin/options.py @@ -1516,6 +1516,10 @@ class InlineModelAdmin(BaseModelAdmin): """Hook for customizing the number of extra inline forms.""" return self.extra + def get_max_num(self, request, obj=None, **kwargs): + """Hook for customizing the max number of extra inline forms.""" + return self.max_num + def get_formset(self, request, obj=None, **kwargs): """Returns a BaseInlineFormSet class for use in admin add/change views.""" if 'fields' in kwargs: @@ -1543,7 +1547,7 @@ class InlineModelAdmin(BaseModelAdmin): "exclude": exclude, "formfield_callback": partial(self.formfield_for_dbfield, request=request), "extra": self.get_extra(request, obj, **kwargs), - "max_num": self.max_num, + "max_num": self.get_max_num(request, obj, **kwargs), "can_delete": can_delete, } |
