MCPcopy
hub / github.com/django/django / __len__

Method __len__

django/forms/models.py:1452–1456  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1450 yield self.choice(obj)
1451
1452 def __len__(self):
1453 # count() adds a query but uses less memory since the QuerySet results
1454 # won't be cached. In most cases, the choices will only be iterated on,
1455 # and __len__() won't be called.
1456 return self.queryset.count() + (1 if self.field.empty_label is not None else 0)
1457
1458 def __bool__(self):
1459 return self.field.empty_label is not None or self.queryset.exists()

Callers

nothing calls this directly

Calls 1

countMethod · 0.45

Tested by

no test coverage detected