Skip to content

Commit

Permalink
adding fallback for QuerySet.exists() on Django 1.1.x (introduced at c…
Browse files Browse the repository at this point in the history
  • Loading branch information
git2samus committed Jun 9, 2010
1 parent eb236b2 commit 880f7d1
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions mailer/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,13 @@ def has_address(self, address):
is the given address on the don't send list?
"""

if self.filter(to_address__iexact=address).exists():
return True
else:
return False
queryset = self.filter(to_address__iexact=address)
try:
# Django 1.2
return queryset.exists()
except AttributeError:
# AttributeError: 'QuerySet' object has no attribute 'exists'
return bool(queryset.count())


class DontSendEntry(models.Model):
Expand Down

0 comments on commit 880f7d1

Please sign in to comment.