What does pk__in mean in Django?

django, python

Solution

It means, give me all objects of model `Model` that either have `1`,`2` or `3` as their primary key.

See Field lookups - in.

You get a list of objects back you can show them in the template like every other list, using the `for` template tag:

{% for object in objects %}
    Some value: {{ object.value }}
{% endfor %}

To learn how to create a Django application you should read the tutorial or the Django book.

Problem

``` Model.objects.filter(pk__in=[list of ids]) ``` and ``` Model.objects.filter(pk__in=[1,2,3]) ``` How do I show this data in a template? ``` def xx(request): return HttpResponse(Model.objects.filter(pk__in=[1,2,3])) ```

Original source