0
0
Djangoframework~10 mins

Celery installation and setup 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 Celery in your Django project.

Django
from celery import [1]
Drag options to blanks, or click blank then click option'
Aapp
BCelery
Ctask
Dworker
Attempts:
3 left
💡 Hint
Common Mistakes
Importing 'app' or 'task' instead of 'Celery'.
Using lowercase 'celery'.
2fill in blank
medium

Complete the code to create a Celery app instance named 'app'.

Django
app = Celery('[1]')
Drag options to blanks, or click blank then click option'
Amyproject
Bcelery_app
Cdjango_project
Dtasks
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'celery_app' or 'tasks' which are not project names.
Using 'django_project' as a generic name.
3fill in blank
hard

Fix the error in the code to load Django settings into Celery.

Django
app.config_from_object('[1]')
Drag options to blanks, or click blank then click option'
Adjango.settings
Bsettings
Cdjango.conf.settings
Ddjango.conf:settings
Attempts:
3 left
💡 Hint
Common Mistakes
Using dot notation instead of colon.
Using just 'settings' without module.
4fill in blank
hard

Fill both blanks to auto-discover tasks in Django apps.

Django
app.[1]_tasks()  # Auto-discover tasks in installed apps

app.conf.broker_url = '[2]'
Drag options to blanks, or click blank then click option'
Aautodiscover
Bredis://localhost:6379/0
Cdiscover
Damqp://guest@localhost//
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'discover_tasks' instead of 'autodiscover_tasks'.
Using AMQP URL when Redis is expected.
5fill in blank
hard

Fill all three blanks to define a simple Celery task function.

Django
from celery import shared_task

@shared_task
def [1](x, y):
    return x [2] y  # Returns sum

result = [3](4, 5).delay()
Drag options to blanks, or click blank then click option'
Aadd
B+
Dsum
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'sum' as function name which is a built-in function.
Using '-' or '*' instead of '+'.