Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

自定义Filter报错 #48

Closed
istarmeow opened this issue May 22, 2019 · 2 comments
Closed

自定义Filter报错 #48

istarmeow opened this issue May 22, 2019 · 2 comments
Labels
bug Something isn't working

Comments

@istarmeow
Copy link

bug描述
简单的描述下遇到的bug:

class EcpidFilter(admin.SimpleListFilter):
    title = _('是否已加密id')
    parameter_name = 'ecpid'

    def lookups(self, request, model_admin):
        # 第一个对应查询参数的值,第二个对应下拉列表选项
        return (
            ('0', _('未加密')),
            ('1', _('已加密')),
        )

    def queryset(self, request, queryset):
        if self.value() == '0':
            return queryset.filter(ecpid__isnull=True).all()
        elif self.value() == '1':
            return queryset.filter(ecpid__isnull=False).all()

admin中自定义字段过滤报错

list_filter = ['author',  EcpidFilter]

image

环境

1.操作系统:
2.python版本:3.7
3.django版本:2.1
4.simpleui版本:2.1

@istarmeow istarmeow added the bug Something isn't working label May 22, 2019
@WalkerWang731
Copy link
Collaborator

这个问题我也发现了,稍后我看看,会针对此问题进行修复,下个版本会修复这个问题。

@newpanjing
Copy link
Owner

已经修复此bug,请升级到2.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants