Answer the question
In order to leave comments, you need to log in
How to use response in signal?
Kind!
I can't figure out how to use the response from send.
The docs say:
Both send() and send_robust() return a list of tuple pairs [(receiver, response), ... ], representing the list of called receiver functions and their response values.
from django.dispatch import Signal
requested = Signal(providing_args=["request"])
from signals import requested
def foo (request):
....
requested.send(sender=None, request=request)
from django.dispatch import receiver
from signals import requested
@receiver(requested)
def foo1(sender, **kwargs):
request = kwargs['request']
###Как тут вернуть response?
Answer the question
In order to leave comments, you need to log in
The debugger and prints can help you understand what request is
request = [(receiver, response), ... ]
response = request[0][1]
Hmm... what if we just write return "bar"
in a function that catches a signal?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question