0
0
Djangoframework~10 mins

Why background tasks matter in Django - Test Your Understanding

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

Complete the code to import the module for background tasks in Django.

Django
from django_q.[1] import async_task
Drag options to blanks, or click blank then click option'
Atasks
Basync_task
Cmodels
Dviews
Attempts:
3 left
💡 Hint
Common Mistakes
Importing 'async_task' directly from 'django_q'.
Trying to import from 'models' or 'views' which are unrelated.
2fill in blank
medium

Complete the code to schedule a background task that sends an email.

Django
async_task('[1]', user.id, subject='Welcome')
Drag options to blanks, or click blank then click option'
Amail_send
Bsend_mail
Cemail_send
Dsend_email
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect function names like 'send_email' or 'email_send'.
Confusing the order of arguments.
3fill in blank
hard

Fix the error in the code to correctly run a background task with arguments.

Django
async_task('[1]', user.id, retries=3)
Drag options to blanks, or click blank then click option'
Asend_mail()
Bsend_mail(user.id)
Csend_mail
Dsend_mail(user)
Attempts:
3 left
💡 Hint
Common Mistakes
Including parentheses in the function name string.
Passing the function call instead of the function name.
4fill in blank
hard

Fill both blanks to create a background task that retries on failure and logs the result.

Django
async_task('[1]', user.email, retries=[2])
Drag options to blanks, or click blank then click option'
Asend_mail
Bretry
C3
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'retry' as the function name.
Setting retries to a string instead of a number.
5fill in blank
hard

Fill all three blanks to define a background task that updates user stats, logs success, and sets a timeout.

Django
async_task('[1]', user.id, on_success='log_success', timeout=[2], retries=[3])
Drag options to blanks, or click blank then click option'
Aupdate_stats
B60
C2
Dsend_mail
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'send_mail' instead of 'update_stats' for this task.
Setting timeout or retries to wrong values.