Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to import Django's main module.
Django
import [1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Importing unrelated libraries like Flask or React.
Trying to import a module that doesn't exist.
✗ Incorrect
Django is a Python web framework, so you import it using import django.
2fill in blank
mediumComplete the code to create a new Django project named 'myproject'.
Django
django-admin startproject [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using generic names like 'app' or 'website' instead of 'myproject'.
Misspelling the project name.
✗ Incorrect
The command django-admin startproject myproject creates a new Django project named 'myproject'.
3fill in blank
hardFix the error in the command to run the Django development server.
Django
python manage.py [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'startserver' or 'serve' which are not valid Django commands.
Misspelling 'runserver'.
✗ Incorrect
The correct command to start Django's development server is python manage.py runserver.
4fill in blank
hardFill both blanks to define a simple Django view that returns 'Hello World'.
Django
from django.http import [1] def home(request): return [2]('Hello World')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using JsonResponse or render without proper context.
Forgetting to import the response class.
✗ Incorrect
Django views return an HttpResponse object to send text back to the browser.
5fill in blank
hardFill all three blanks to add a URL pattern for the home view in Django.
Django
from django.urls import [1] from .views import [2] urlpatterns = [ [3]('', home), ]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'url' instead of 'path' which is deprecated.
Not importing the view function correctly.
✗ Incorrect
Use path to define URL patterns and import the home view to connect it.