Opened 7 years ago
Closed 6 years ago
#29431 closed Cleanup/optimization (needsinfo)
inline_admin should have possibility don't generate empty inline form.
Reported by: | Maxim Danilov | Owned by: | Daniel Rios |
---|---|---|---|
Component: | contrib.admin | Version: | |
Severity: | Normal | Keywords: | InlineFormSet, optimization |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description (last modified by )
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.
Change History (4)
comment:1 by , 7 years ago
Description: | modified (diff) |
---|
comment:2 by , 6 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:3 by , 6 years ago
Description: | modified (diff) |
---|
comment:4 by , 6 years ago
Resolution: | → needsinfo |
---|---|
Status: | assigned → closed |
Note:
See TracTickets
for help on using tickets.
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_permissionPlease feel free to re-open the ticket with more info.