在Django数据表中切片

时间:2019-01-18 11:39:33

标签: django django-datatable

class OrderConsentsEnterpriseJson(BaseDatatableView):
    model = CONSENTS
    columns = ['iConsentID','iMSISDN','iCommID','iPurpose']
    order_columns = ['iConsentID','iMSISDN','iCommID','iPurpose']
    def get_initial_queryset(self):
        msisdn=9898989898
        EntityID=1
        resultset=CONSENTS.objects.filter(iStatus= settings.STATUS_FLAGS['Active'],iEntityID=EntityID,iMSISDN=int(msisdn)).order_by('-iConsentID')[:10]
        return resultset
    def render_column(self, row, column):
        if column == 'iPurpose':
            if row.iPurpose==1:
                return 'All'
            elif row.iPurpose==2:
                return 'Promotional'
            else:
                return 'Service'
        if column == 'iStatus':
            if row.iStatus==1:
                return 'Opted-in'
            elif row.iStatus==0:
                return 'Opted-out'
            else:
                return 'Expired'
        if column == 'iCommID':
            communication_mode=
             COMMUNICATION_MASTER.objects.filter(iCommID=row.iCommID).first()
            return communication_mode.vcCommunicationMode

        return super(OrderConsentsEnterpriseJson, self).render_column(row, column)      

我想在页面load ..上获取10条记录,但出现以下错误AssertionError:采取切片后无法过滤查询。

0 个答案:

没有答案