Opened 14 years ago

Closed 14 years ago

#14106 closed (invalid)

Duplicate emails without fully qualified project imports

Reported by: tom_simpson Owned by: nobody
Component: Uncategorized Version: 1.2
Severity: Keywords:
Cc: tom@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When sending emails via signals.

Emails become duplicated if you are not using fully qualified imports for your project.

{from app.models import ....} causes duplicate emails being sent.

However,

{from project.app.models import ....} seems to resolve the issue

Thanks,
Tom

Change History (2)

comment:1 by tom_simpson, 14 years ago

It seems that all signals are being called twice by the models, not just the email sending function.

Thanks,
Tom

comment:2 by Russell Keith-Magee, 14 years ago

Resolution: invalid
Status: newclosed

from project.app.models import foo and from app.models import foo are two separate imports, resulting in two separate modules. As a result, if you have a signal registered in foo.py it causes two separate signals to be registered.

This is a language feature of Python; it isn't something that Django is in a position to fix.

That said, some of the discussions around the logging improvements under consideration for Django 1.3 may result in a better way to register signals, which will avoid this problem by providing a way to register signals that isn't prone to accidental duplication as a result of import paths.

Note: See TracTickets for help on using tickets.
Back to Top