.filter querysets不显示数据。的Django1.11

时间:2019-06-03 12:09:26

标签: python django

我尝试使用.filter过滤一些数据,但不显示。当我尝试不过滤就显示所有内容时,它会显示所有内容...但是当我尝试过滤时,没有任何效果。

class Part_Time_DM(models.Model):
    Location=models.CharField(max_length=15, default="location")

def PartFilterView(request):
   qs = Part_Time_DM.objects.all()

   location_query= request.GET.get('location')

   qs = qs.filter(location__icontains=location_query)



   return render(request, 'home.html', {"qs" : qs})
<!-- Team -->
        <section id="team" class="pb-5">
            <div class="container">
                <div class="row">
                    {% for fulls in qs %}
                    <!-- Team member -->
                    <div class="col-xs-12 col-sm-6 col-md-4">
                        <div class="card two">
                            <img src="{{ fulls.Profile_picture.url }}" alt="John" style="width:40%">
                            <h1>{{fulls.Name}}</h1>
                            <p class="title two">Location : {{fulls.Location}}</p>
                            <br>
                        </div>
                    </div>
                    <!-- ./Team member -->

                    {% endfor %}

                </div>
            </div>
        </section>
        <!-- Team -->

0 个答案:

没有答案