Comments (2)
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.
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)
- What is the purpose of send_loop HOT 3
- Allow setting priority without using django-mailer specific functions
- Please start with the "why?" and the benefits HOT 2
- Having problem on django-mailer on using with djoser HOT 6
- Condense logging HOT 2
- send_loop busy loops when there are deferred messages HOT 1
- TypeError sequence item 1: expected str instance, NoneType found HOT 5
- Forecast for the next deploy? HOT 7
- Fix issue with BigAutoField
- More granular control of how many emails to send. HOT 1
- use unittest.mock instead of mock HOT 2
- How to access subject line from db HOT 4
- Stop retrying/deferring after n failures HOT 1
- Hello HOT 2
- lockfile dependency is deprecated
- Webmail Smtp HOT 3
- feature request: release email(s) from admin under interface under Message actions HOT 2
- Issue running runmailer_pg HOT 1
- Define your own database table for the email queue HOT 3
- Ability to disable message logs
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-mailer.