(self)
| 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() |