Code Monkey home page Code Monkey logo

Comments (2)

spookylukey avatar spookylukey commented on September 25, 2024

The only way to do it is as follows:

for log in MessageLog.objects.all():
    if "[email protected]" in log.email.to:
        do_something()

This is very bad in terms of performance - you have to load all the MessageLog records from the DB to find the one you are interested in. There is no way to do the filtering in the DB, because we don't store that field separately, and it is found only in data stored using Python's "pickle" format. This is because MesssageLog is just not designed for this - it is designed with django-mailers needs in mind, not your use case.

The answer is "don't do this". If you need a list of all messages sent to a user, create your own model that has a foreign key to your 'person' model, and use this. At the same time as sending mail (with django-mailer or any other mail backend), you should store a record in this table, storing all the details you need. To populate this table initially you may be able to use the data in the MessageLog table. After this initial population, you shouldn't be using MessageLog at all.

from django-mailer.

ebdavison avatar ebdavison commented on September 25, 2024

Thank you for that code. I was not able to get that much working before and when/if needed that will definitely come in handy. As to the separate model, I have started doing this but every once in a while I need to go back to the original message ID and stats returned from the SMTP server so will reserve the above code for an admin details sort of function.

This is VERY much appreciated.

from django-mailer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.