Ticket #4399: 5358_added_nonzero_for_queryset.diff

File 5358_added_nonzero_for_queryset.diff, 593 bytes (added by Michael Axiak <axiak@…>, 17 years ago)

Simple patch to add __nonzero__ to queryset

  • django/db/models/query.py

     
    164164        combined._filters = self._filters | other._filters
    165165        return combined
    166166
     167    def __nonzero__(self):
     168        """
     169        Returns True if an element exists.
     170        """
     171        return len(self.values(self.model._meta.pk.name)[:1]) > 0
     172
    167173    ####################################
    168174    # METHODS THAT DO DATABASE QUERIES #
    169175    ####################################
Back to Top