Domanda

I am using mezzanine in my project, but admin inline just puts 20 additional extra inlines, I need more inlines, but Add another button is missing.

How can I solve this problem?

È stato utile?

Soluzione

I think it's a bug of mezzanine, max_num can't get what I want, but extra do, which is different with Django docs

Django 1.6.2 mezzanine 3.0.5

from mezzanine.core.admin import StackedDynamicInlineAdmin
class ABinInline(StackedDynamicInlineAdmin):
    model = Reaction
    extra = 1000 # similar to max_num in mezzanine 3.0.5
    #max_num = 1000 # doesn't work here

StackeInline and TabularInline are not specific to Mezzanine, rather they are Django.  You can read up on them here: https://docs.djangoproject.com/en/1.6/ref/contrib/admin/#django.contrib.admin.InlineModelAdmin.extra

To briefly answer some of your questions, they don't have an add another button and will show as many "extra" as you specify in the admin class associated with the particular inline.

If you use the Mezzanine's dynamic inlines you will by default have 20 extra rows (although they are hidden until you click add another, which reveals one at a time).  You can override this so if you for example set extra to 0 I imagine clicking add another would do nothing.

To delete data you have to click the x which makes the row go red.  Then you need to save the model.  For example click save and continue editing and you should see that the data was deleted.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top