0
0
Djangoframework~10 mins

Signal dispatch process in Django - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the Django signal dispatcher.

Django
from django.dispatch import [1]
Drag options to blanks, or click blank then click option'
Areceiver
Bsend
CSignal
Dconnect
Attempts:
3 left
💡 Hint
Common Mistakes
Importing 'receiver' instead of 'Signal'.
Trying to import 'send' which is a method, not a class.
2fill in blank
medium

Complete the code to connect a receiver function to a signal.

Django
my_signal.[1](receiver=my_receiver)
Drag options to blanks, or click blank then click option'
Aregister
Bconnect
Cdispatch
Dsend
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'send' which triggers the signal instead of connecting.
Using 'register' which is not a Django signal method.
3fill in blank
hard

Fix the error in sending a signal with a sender argument.

Django
my_signal.send(sender=[1])
Drag options to blanks, or click blank then click option'
ANone
Brequest
Cself
DMyModel
Attempts:
3 left
💡 Hint
Common Mistakes
Passing 'self' which is an instance, not a class.
Passing 'None' which is allowed but not typical for sender.
4fill in blank
hard

Fill both blanks to define and send a custom signal with a named argument.

Django
my_signal = Signal(providing_args=[[1]])
my_signal.send(sender=MyModel, [2]=42)
Drag options to blanks, or click blank then click option'
A'value'
Bvalue
C'count'
Dcount
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes when sending the argument name.
Not matching the argument name in providing_args and send.
5fill in blank
hard

Fill all three blanks to create a receiver function and connect it to a signal.

Django
@receiver([1], sender=[2])
def my_receiver(sender, **kwargs):
    print([3])
Drag options to blanks, or click blank then click option'
Amy_signal
BMyModel
Ckwargs.get('count')
Dsender
Attempts:
3 left
💡 Hint
Common Mistakes
Using the sender instance instead of class.
Printing sender instead of the custom argument.
Not using the @receiver decorator properly.