I am simply stumped. I'm trying to implement a textbook case of `prefect_related` in my django app, but it simply won't work. Here are the relevant models:

```
class CanUseUnit(models.Model):

  objects = UnitManager()

  ingredient = models.ForeignKey('Ingredient', db_column='ingredient', related_name='useable_units')
  unit = models.ForeignKey('Unit', related_name='used_by', db_column='unit', limit_choices_to=models.Q(parent_unit__exact=None))

```

Please note that although this model has a custom Manager, this is a simple subclass of `models.Managar` with only 1 method named `get_all_info()`, so I don't think that has anything to do with my problem:

I'm trying to query all Ingredients, and prefetch their useable units. This is my Django query:

```
def list_ingredients(request):
  ingredients = Ingredient.objects.all().order_by('accepted', 'name').prefetch_related('useable_units')
  for ingredient in ingredients:
    print(ingredient.useable_units.all())

  return render(request, 'admin/list_ingredients.html', {'ingredients': ingredients})

```

But Django seems to hit the database on every `print` statement... What is going on?

EDIT:

It seems that the caching does work when called from a template. When I leave out the print statement in the view above, and visit the page containing following template code:

```
{% for ingredient in ingredients %}
<tr>
  <td><a href="/ingredients/edit/{{ ingredient.id }}/">{{ ingredient.name }}</a></td>
  <td align="center">{{ ingredient.useable_units.count }}</td>
</tr>

{% endfor %}

```

The database is only getting hit twice (which I would expect, once for Ingredients, and once for the prefetch\_related).

SOLVED:
Well, the problem seemed to have resolved itself... I kept trying and restarting the test server, and suddenly it stopped querying for every Ingredient. Not sure what happened, but I'm glad its resolved.