0
0
Djangoframework~10 mins

Django project structure walkthrough - 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 settings module in a project.

Django
from django.conf import [1]
Drag options to blanks, or click blank then click option'
Amodels
Burls
Csettings
Dviews
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'urls' instead of 'settings' for configuration import.
Confusing 'models' or 'views' with settings.
2fill in blank
medium

Complete the code to define the main URL configuration file in a Django project.

Django
urlpatterns = [
    path('admin/', admin.site.[1]),
]
Drag options to blanks, or click blank then click option'
Aurls
Bsite
Clogin
Dindex
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'index' or 'login' which are not valid attributes here.
Confusing 'urls' as a method instead of an attribute.
3fill in blank
hard

Fix the error in the Django app's models import statement.

Django
from [1] import models
Drag options to blanks, or click blank then click option'
Adjango.db
Bviews
Cdjango.db.models
Ddjango
Attempts:
3 left
💡 Hint
Common Mistakes
Importing directly from 'views' or 'django' which is incorrect.
Using 'django.db.models' which is not the correct import path.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps app names to their config classes.

Django
app_configs = {app: [1] for app in apps if app [2] 'auth'}
Drag options to blanks, or click blank then click option'
Aapp.capitalize() + 'Config'
Bapp.startswith('auth')
Capp.endswith('auth')
Dapp.lower()
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'endswith' instead of 'startswith' for filtering.
Not capitalizing app names correctly.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension mapping model names to their fields if the model has more than 3 fields.

Django
model_fields = {model.[1]: model._meta.[2] for model in models if len(model._meta.[3]) > 3}
Drag options to blanks, or click blank then click option'
A__name__
Bfields
Dobjects
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'objects' instead of 'fields' to access model fields.
Not using .__name__ to get the model name.