coddingtonbear / django-mailbox

Import mail from POP3, IMAP, local email mailboxes or directly from Postfix or Exim4 into your Django application automatically.
MIT License
355 stars 164 forks source link

save() prohibited to prevent data loss due to unsaved related object 'Mailbox' #219

Open sane5ek opened 4 years ago

sane5ek commented 4 years ago

If you have Djongo (MongoDB Connector based on pymongo) in your project:

save() prohibited to prevent data loss due to unsaved related object 'Mailbox'

when trying to

mailbox.get_new_mail()

That's because Djongo use Model._id instead of Model.id field. When trying to save mailbox object again, that creates new database record with the same fields as mailbox object.

My fix - import models from djongo app in django_mailbox.models file and adding field

_id = models.ObjectIdField()

in Mailbox model.

pfouque commented 8 months ago

Hello, Do you have a stack trace or can you pinpoint the line generating this error? Thanks