I have some models with a large number of inlines. Since not all are needed for every object I declared the inline model with extra = 0
so that a small add +
appeared on the inline.
However, this seems to no longer work in django 1.5. If extra = 0
is set, the inline is no longer editable.
Is there a way to get the 1.4 behavior into 1.5?
Example Code:
class ModelInline(admin.StackedInline):
model = MyModel
extra = 0
class OtherModelAdmin(admin.ModelAdmin)
inlines = [ModelInline]
admin.site.register(OtherModel, OtherModelAdmin)
Edit (some screens):
Django 1.4:
Django 1.5:
(Hinzufügen == add)
This is already happen before.
The new javascript made this impossible because the "Add Another" button
was controlled by max_num, and ignored a value of 0.
The javascript ignored a value of 0 because max_num has a default value of 0,
and all the code using it had taken to equating max_num = 0 with being "off".
So you can't actually have a maximum of 0. It's not possible.
There is a patch create by Gabrial Hurley to restores desired behaviour without breaking anything else. This is 3years ago and I don't know if it still working for Django 1.5. Just try :)
https://code.djangoproject.com/attachment/ticket/13023/13023_inlines_patch.diff
Here is the ticket for that same bug (3 years ago):
https://code.djangoproject.com/ticket/13023
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With