1

それが私がやっていることなのか、それともバグなのかはわかりませんが、 TabularInline(grappelli を使用する django 管理者) の追加ボタンで奇妙な動作が発生します。私のインラインクラスは次のとおりです。

class FieldInline(admin.TabularInline):
    model = models.Field
    classes = ('grp-collapse grp-closed',)

    fields = ('number', 'year', 'area')
    extra = 0

    def has_add_permission(self, request):
        return False

    def has_delete_permission(self, request, obj):
        return False

インラインフォームセットを折りたたむと追加ボタンが表示されますが、開くと消えます。関連するjqueryを掘り下げてみましたが、言語にあまり慣れていないため、何を探しているのかよくわかりません。

他の誰かがこの動作を取得しますか? 明らかな解決策はありますか?

4

2 に答える 2

0

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.

Gabrial Hurley によって作成されたパッチがあり、他に何も壊さずに望ましい動作を復元します。これは 3 年前のもので、Django 1.5 でまだ機能しているかどうかはわかりません。ちょうど試して :)

https://code.djangoproject.com/attachment/ticket/13023/13023_inlines_patch.diff

同じバグ (3 年前) のチケットは次のとおりです。

https://code.djangoproject.com/ticket/13023

ケビンからの経験:

I ran into the same issue because I had the static admin content in a directory that was outside of django's install. Copying the Django 1.5 static content from django/contrib/admin/static/admin/js/ to STATIC_ROOT/admin/js fixed the issue.

于 2013-04-12T13:59:30.913 に答える