Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of http://github.com/michaelcetrulo/django-mailer

  • Loading branch information...
commit 3d8548d879c197ece815d067a892fc0095c1518a 2 parents 6c7d264 + 296cfba
@spookylukey spookylukey authored
Showing with 14 additions and 5 deletions.
  1. +7 −1 mailer/engine.py
  2. +7 −4 mailer/models.py
View
8 mailer/engine.py
@@ -7,7 +7,13 @@
from django.conf import settings
from django.core.mail import send_mail as core_send_mail
-from django.core.mail import get_connection
+try:
+ # Django 1.2
+ from django.core.mail import get_connection
+except ImportError:
+ # ImportError: cannot import name get_connection
+ from django.core.mail import SMTPConnection
+ get_connection = lambda backend=None, fail_silently=False, **kwds: SMTPConnection(fail_silently=fail_silently)
from mailer.models import Message, DontSendEntry, MessageLog
View
11 mailer/models.py
@@ -163,10 +163,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):
Please sign in to comment.
Something went wrong with that request. Please try again.