与Django icontains相反

时间:2015-06-23 02:19:23

标签: django django-filter

如何更新以下查询,以便我需要删除你喜欢的“29”(u__inotcontains =“29”)?

    <h1>Crib Reader</h1>

<table align="center">
    <tr>
        <td style="width: 134px; ">
            <input type="radio" name="Reader" value="Book" style="vertical-align: middle" checked="checked">Book
            <input type="radio" name="Reader" value="Story" style="vertical-align: middle">Story
        </td>
        <td style="width: 162px; "><input type="text" name="Name" style="height: 20px;"></td>
        <td> <button type="button">Add</button> </td>
    </tr>
</table>
<br></br>
<table align="center" style="width: 316px; ">
    <tr>
        <td style="width: 115px; ">
            Books<br></br>
            <select id="Books" style="width: 100px; ">
                <option value=""></option>
            </select>
        </td>
        <td>
            <button type="button">Load</button>
        </td>

        <td style="width: 115px; ">
            Stories<br></br>
            <select id="Stories" style="width: 100px; ">
                <option value=""></option>
            </select>
        </td>
                    <td>
            <button type="button">Load</button>
        </td>
    </tr>
</table>
<hr>


  </body>
</html>

2 个答案:

答案 0 :(得分:0)

您需要使用Q objects。以下是代码的示例。

from django.db.models import Q

model1_obj = xx.objects.filter(date_generated__gte=1429142401, date_generated__lte=1431648001, ~Q(s__icontains="28"))

要排除它,请使用exclude查询。您可以阅读details here。代码将是这样的。

来自django.db.models import Q

model1_obj = xx.objects.filter(date_generated__gte=1429142401, date_generated__lte=1431648001).exclude(~Q(s__icontains="28"))

答案 1 :(得分:0)

我通过以下方式实现了它: DestinationViewController *destinationVC = segue.destinationViewController; destinationVC.delegate = self;