[Answer]-'DbBackend' object has no attribute 'use_ssl' django

1👍

The problem is that your Django application uses a custom email backend (specified by the EMAIL_BACKEND setting), that custom email backend apparently subclasses django.core.mail.backends.smtp.EmailBackend and that class has changed between Django 1.6 and Django 1.8 . Your custom email backend is not compatible with the new implementation of django.core.mail.backends.smtp.EmailBackend.

I would be able to give you a more detailed answer if you would post the DbBackend implementation but my guess is that you override EmailBackend.__init__ without calling super(DbBackend, self).__init__.

Edit: You are indeed not calling super(DbBackend, self).__init__ in EmailBackend.__init__ but super(EmailBackend, self).__init__.

DbBackend‘s version of __init__ is in fact a copy/paste of the Django 1.6 version of EmailBackend.__init__ without the lock instantiation.

The easiest solution to your problem would be to not override the __init__ method. If you don’t want locking, don’t use the lock in send_messages but let it be instantiated.

I do not know why you want to get rid of locking but if you would keep it, the implementation of DbBackend would be as simple as:

class DbBackend(EmailBackend):
    def send_messages(self, email_messages):           
        if not email_messages:
            return
        for message in email_messages:
            msg = Message()
            msg.email = message
            msg.save()

        super(DbBackend, self).send_messages(email_messages)

And it would not break on further Django upgrades.

👤aumo

Leave a comment