12👍
I’m not positive, but I’d say it’s doubtful. Kinda more important is that the idea behind signals is that they should be atomic. A signal handler should respond the signal and shouldn’t care about other signals. Relying on the order of two unrelated signals (obviously you can rely on the order of pre_save and post_save for example) is not safe in general. So even though I don’t have a firm answer on your question, I’d offer the advice that yo should think carefully about the design.
19👍
No, you cannot change the order that signals are executed.
Signal priority has been proposed, but the core developers have said they will not implement this feature:
- Django-Rest-Framework serializer class meta
- How do I write a Django model with ManyToMany relationsship with self through a Model
- RexProScriptException transaction is not open in Django with Titan (graph DB)
4👍
I know this is a very old question, but I was surprised by the lack of anything I found related to a workaround for handler ordering. So here is a subclass of the dispatcher which implements priorities.
from django.dispatch import Signal as BaseSignal
from django.dispatch.dispatcher import _make_id
class Signal(BaseSignal):
def connect(self, receiver, sender=None, weak=True, dispatch_uid=None, priority=50):
if dispatch_uid is None:
dispatch_uid = _make_id(receiver)
inner_uid = '{0}{1}'.format(priority, dispatch_uid)
super(Signal, self).connect(receiver, sender=sender, weak=weak, dispatch_uid=inner_uid)
self.receivers.sort()
While this won’t help you with third-party apps, you can create your own signals with this class, and attach them to the built-in signals, allowing you to order the handlers within your own app.
- How to change language from Django URL?
- Casting from base Model instance to derived proxy Model in Django?
0👍
Have you considered using one signal that calls create_social_profile and create_user_profile. perhaps you could attach this signal to post_save?
- PyDev and Django: how to restart dev server?
- What is the best HTML approach when form inputs are spread throughout the page?