Using craft.entries to return entries with empty entries field I'm new to all this. Is it possible to use craft.entries to return all entries with an empty entries field? Something like:

{% set drinksWithNoIngredients = craft.entries.section("drinks").ingredients(":empty:") %}
{% for drink in drinksWithNoIngredients %}
    &lt;p&gt;Do something with {{ drink.title }}...&lt;/p&gt;


where ingredients is an entries field handle. This doesn't seem to work on entries fields, though. Or maybe I could do some kind of relatedTo magic, where the targetElement is some kind of special null value?

An alternative seems to be this:

{% set drinksWithNoIngredients = craft.entries.section("drinks") %}
{% for drink in drinksWithNoIngredients %}
    {% if not drink.ingredients.total() %}
    &lt;p&gt;Do something with {{ drink.title }}...&lt;/p&gt;


But doing it that way calls .total() on every drink. Is that going to cause performance problems if I have a lot of drinks?
You were on the right track using relatedTo. But as there's no notRelatedTo parameter, you'd first have to get all drinks that are related to any ingredient and those entries can then be removed from a new ElementCriteriaModel, that returns all your drinks, using Craft's without filter. Instead of passing whole element models, you should better use this filter with element IDs (→ Why is the Craft without filter not working correctly and how to debug?). To get them just make use of the ids() method.

{% set ingredients = craft.entries.section('ingredients').limit(null) %}
{% set drinksWithIngredientsIds = craft.entries.section('drinks').relatedTo({targetElement: ingredients}).limit(null).ids() %}

{% set drinksWithNoIngredients = craft.entries.section('drinks')|without(drinksWithIngredientsIds) %}