首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Django-grappelli添加按钮在添加权限为假时在内联中可见

Django-grappelli添加按钮在添加权限为假时在内联中可见
EN

Stack Overflow用户
提问于 2013-04-12 16:33:29
回答 2查看 936关注 0票数 1

我不确定是我在做什么,还是有个bug,但我在TabularInline中的add按钮有一些奇怪的行为(使用grappelli的django admin )。我的内联类是:

代码语言:javascript
复制
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,但我不太熟悉这种语言,所以我不太确定我在寻找什么。

其他人也有这种行为吗?有明显的解决方案吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-04-12 21:24:12

这是一个bug。我在github上打开了一个问题,因为我们将它用作Grappelli (https://github.com/sehmaschine/django-grappelli/issues/316)的问题跟踪器。

看过这个之后:隐藏按钮的可见性是一个css问题,用https://github.com/sehmaschine/django-grappelli/commit/da4d500c5e3b8f8dba5709b0378396131fad361d修复了这个问题。

票数 2
EN

Stack Overflow用户

发布于 2013-04-12 21:59:31

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

这是同一个bug的罚单(3年前):

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

来自Kevin on experience:

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.

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15966633

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档