Reputation: 1037
I have a main_app
, and app2
. main_app
is essentially a list of items with data, and app2
has more information about said items.
main_app
isn't supposed to know about app2
, but app2
can import from main_app
.
Within main_app/signals.py
, I have
import django.dispatch
mysignal = django.dispatch.Signal(providing_args=['uid'])
In main_app/views.py
, I have a view which renders various main_templates
, containing the details of the item, a view for editing, and one for submitting said edited data. The idea is that a signal is sent when each of those is called and, app2
receives this. main_template
uses the "with
" call to get template2
and that app's information.
In app2/processes.py
I have the following:
import django.dispatch
from django.dispatch import receiver
import my models
from main_app.signals import mysignal, (mysignal2, etc)
Then for each method, I have
@receiver(mysignal)
def foo(sender, **kwargs) etc
OK... So, in main_app/views.py
, if I have the line:
from app2.processes import mysignal, mysignal2 etc
Everything works smoothly. But I want to remove any reliance on app2
in main_app
. As far as I am concerned, app2
is just importing these signals from main_app/signals.py
.
But if I try to get rid of the above line and put the following into main_app/views.py
from main_app.processes import mysignal, my...
It doesn't work...I don't get an error but the data from app2 doesn't render into the template, and I really don't see why....Any ideas?
Upvotes: 2
Views: 1888
Reputation: 12138
Your signal receivers in app2 are probably not registered. Simple check: put raise Exception("I was imported!");
as the first line in app2/processes.py
. You probably will never see that exception. You will have to make sure the signal receivers are being registered. You can do this by import app2.processes
somewhere Django will look. For example in app2/models.py
.
Upvotes: 5