[Django] #29431: inline_admin should have possibility don't generate empty inline form.

29 views
Skip to first unread message

Django

unread,
May 22, 2018, 12:39:13 PM5/22/18
to django-...@googlegroups.com
#29431: inline_admin should have possibility don't generate empty inline form.
-------------------------------------+-------------------------------------
Reporter: danilovmy | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: | Version:
contrib.admin | Keywords: InlineFormSet,
Severity: Normal | optimization
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
for example in admin.py:

class my_model_inline(admin.StackedInline):
can_add_empty = False

stacked.html after {% for inline_admin_form in inline_admin_formset %} :
{% if opts.can_add_empty or not forloop.last %} - this helped don't call a
formset.empty_form, if i dont need it.

but it is better check it already in: InlineAdminFormSet.__iter__(self),
last iteration.
I think, it makes django better and give more speed.

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

Django

unread,
May 22, 2018, 12:40:13 PM5/22/18
to django-...@googlegroups.com
#29431: inline_admin should have possibility don't generate empty inline form.
-------------------------------------+-------------------------------------
Reporter: danilovmy | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: contrib.admin | Version:
Severity: Normal | Resolution:
Keywords: InlineFormSet, | Triage Stage:
optimization | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by danilovmy:

Old description:

> for example in admin.py:
>
> class my_model_inline(admin.StackedInline):
> can_add_empty = False
>
> stacked.html after {% for inline_admin_form in inline_admin_formset %} :
> {% if opts.can_add_empty or not forloop.last %} - this helped don't call
> a formset.empty_form, if i dont need it.
>
> but it is better check it already in: InlineAdminFormSet.__iter__(self),
> last iteration.
> I think, it makes django better and give more speed.

New description:

for example in admin.py:


{{{
class my_model_inline(admin.StackedInline):
can_add_empty = False
}}}

{{{
stacked.html after {% for inline_admin_form in inline_admin_formset %} :
{% if opts.can_add_empty or not forloop.last %} - this helped don't call a
formset.empty_form, if i dont need it.
}}}

but it is better check it already in: InlineAdminFormSet.__iter__(self),
last iteration.
I think, it makes django better and give more speed.

--

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

Django

unread,
May 26, 2018, 5:40:47 AM5/26/18
to django-...@googlegroups.com
#29431: inline_admin should have possibility don't generate empty inline form.
-------------------------------------+-------------------------------------
Reporter: danilovmy | Owner: Daniel
Type: | Rios
Cleanup/optimization | Status: assigned

Component: contrib.admin | Version:
Severity: Normal | Resolution:
Keywords: InlineFormSet, | Triage Stage:
optimization | Unreviewed
Has patch: 0 | Needs documentation: 0

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

* owner: nobody => Daniel Rios
* status: new => assigned


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

Django

unread,
May 26, 2018, 8:52:41 AM5/26/18
to django-...@googlegroups.com
#29431: inline_admin should have possibility don't generate empty inline form.
-------------------------------------+-------------------------------------
Reporter: danilovmy | Owner: Daniel
Type: | Rios
Cleanup/optimization | Status: assigned
Component: contrib.admin | Version:
Severity: Normal | Resolution:
Keywords: InlineFormSet, | Triage Stage:
optimization | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Old description:

> for example in admin.py:
>

> {{{
> class my_model_inline(admin.StackedInline):
> can_add_empty = False
> }}}
>

>
> {{{
> stacked.html after {% for inline_admin_form in inline_admin_formset %} :
> {% if opts.can_add_empty or not forloop.last %} - this helped don't call
> a formset.empty_form, if i dont need it.
> }}}
>
> but it is better check it already in: InlineAdminFormSet.__iter__(self),
> last iteration.
> I think, it makes django better and give more speed.

New description:

for example in admin.py:


{{{
class my_model_inline(admin.StackedInline):
can_add_empty = False
}}}


`django/contrib/admin/templates/admin/edit_inline/stacked.html` after `{%


for inline_admin_form in inline_admin_formset %}`
{{{
{% if opts.can_add_empty or not forloop.last %}
}}}

this helped don't call a formset.empty_form, if i dont need it.

but it is better check it already in: InlineAdminFormSet.__iter__(self),
last iteration.
I think, it makes django better and give more speed.

--

Comment (by Daniel Rios):

Hi danilovmy,

I'm having trouble reproducing the feature you mention.
Could you provide the whole line from
`django/contrib/admin/templates/admin/edit_inline/stacked.html` on which
the tag should appear, with the new property?

Second, is this different from turning off the add permission? This method
on the Inline removes the blank fields, but also removes the ability to
add a blank form with the `Add another Item` bar below the forms. See:
https://docs.djangoproject.com/en/2.0/ref/contrib/admin/#django.contrib.admin.ModelAdmin.has_add_permission

{{{
def has_add_permission(self, request):
return False
}}}

Please feel free to re-open the ticket with more info.

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

Django

unread,
May 26, 2018, 8:53:23 AM5/26/18
to django-...@googlegroups.com
#29431: inline_admin should have possibility don't generate empty inline form.
-------------------------------------+-------------------------------------
Reporter: danilovmy | Owner: Daniel
Type: | Rios
Cleanup/optimization | Status: closed
Component: contrib.admin | Version:
Severity: Normal | Resolution: needsinfo

Keywords: InlineFormSet, | Triage Stage:
optimization | Unreviewed
Has patch: 0 | Needs documentation: 0

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

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


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

Reply all
Reply to author
Forward
0 new messages