Code

Opened 4 years ago

Closed 4 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: UI/UX:

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

Attachments (0)

Change History (2)

comment:1 Changed 4 years ago by tom_simpson

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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

Thanks,
Tom

comment:2 Changed 4 years ago by russellm

  • Resolution set to invalid
  • Status changed from new to closed

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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.