Q31
Q31 What is the correct way to reference a static file in a Django template?
{% load static %} <img src="{% static 'path/to/file' %}" alt="...">
<img src="{% static 'path/to/file' %}" alt="...">
{% load staticfiles %} <img src="{% static 'path/to/file' %}" alt="...">
<img src="{{ static 'path/to/file' }}" alt="...">
Q32
Q32 How do you create a URL pattern for a view named index in the urls.py file?
path('index/', views.index, name='index')
path('', index, name='index')
path('index/', index, name='index')
path('', views.index, name='index')
Q33
Q33 You get an "ImportError: No module named 'app_name'" when running your Django project.
What is the most likely cause?
The app is not listed in INSTALLED_APPS
The app directory is missing an __init__.py file
The app name is misspelled in the import statement
The app's models are not migrated
Q34
Q34 You encounter a "TemplateDoesNotExist" error.
What is the most likely cause?
The template file is not in the correct directory
The template name is misspelled in the view
The template directory is not listed in TEMPLATES
All of the above
Q35
Q35 Your static files are not being served in development mode.
What is the most likely cause?
DEBUG is set to False
STATIC_URL is incorrect
Static files are not collected
STATICFILES_DIRS is not set
Q36
Q36 What is the purpose of URL routing in Django?
To define database schemas
To map URLs to views
To manage static files
To handle form validation
Q37
Q37 Which function is used to include URL configurations from another app?
path
include
url
config
Q38
Q38 In which file are the URL patterns defined in a Django project?
views.py
urls.py
models.py
settings.py
Q39
Q39 How do you create a URL pattern for the home page view named index?
path('home/', views.index)
path('', views.index)
path('index/', views.home)
path('index/', views.index)
Q40
Q40 How can you pass a parameter in a URL pattern in Django?
path('post/', views.post)
path('post/int:id/', views.post)
path('post/str:id/', views.post)
path('post/
Q41
Q41 What is the purpose of the name parameter in the path function?
To specify the view function name
To specify the URL pattern
To specify the URL pattern name
To specify the parameter type
Q42
Q42 How do you create a URL pattern that includes another URL configuration file?
path('blog/', include('blog.urls'))
path('blog/', include(blog.urls))
path('blog/', blog.urls)
path('blog/', include(blog))
Q43
Q43 How do you reference a named URL pattern in a Django template?
{% url 'pattern_name' %}
{{ url 'pattern_name' }}
{% pattern_name %}
{{ pattern_name }}
Q44
Q44 How do you create a URL pattern with a string parameter named slug?
path('post/str:slug/', views.post)
path('post/
path('post/
path('post/slug:str/', views.post)
Q45
Q45 You encounter a "NoReverseMatch" error.
What is the most likely cause?
The URL pattern name is misspelled
The view function is missing
The template is missing
The URL pattern does not exist
Q46
Q46 What should you check if a URL pattern is not matching as expected?
The URL pattern syntax
The order of URL patterns
The view function
The parameter types
Q47
Q47 What is the primary role of a view in Django?
To handle URL routing
To define the database schema
To process HTTP requests and return responses
To manage static files
Q48
Q48 Which function is used to render a template in a Django view?
render_template
render
template_render
template_response
Q49
Q49 Where are Django templates typically stored within an app?
static/ directory
templates/ directory
media/ directory
views/ directory
Q50
Q50 What is the purpose of the context parameter in the render function?
To specify the URL pattern
To pass data from the view to the template
To define static files
To handle form validation
Q51
Q51 How do you extend a base template in Django?
{% include 'base.html' %}
{% import 'base.html' %}
{% extend 'base.html' %}
{% extends 'base.html' %}
Q52
Q52 Which Django template tag is used to include the content of one template into another?
{% load 'template.html' %}
{% include 'template.html' %}
{% insert 'template.html' %}
{% extends 'template.html' %}
Q53
Q53 How do you pass a variable named name with the value John to a template in a view?
render(request, 'template.html', {'name': 'John'})
render_template('template.html', name='John')
render(request, 'template.html', context={'name': 'John'})
render(request, 'template.html', name='John')
Q54
Q54 Which template tag is used to output the value of a variable in Django?
{{ variable }}
{% variable %}
{{ variablesafe }}
{% include variable %}
Q55
Q55 How do you create a URL pattern that maps to a view named home in views.py?
path('home/', views.home)
path('home/', home)
url('home/', views.home)
url('home/', home)
Q56
Q56 You receive a "TemplateDoesNotExist" error.
What is a likely cause?
The template file is not in the correct directory
The template name is misspelled in the view
The template directory is not listed in TEMPLATES settings
Any of these
Q57
Q57 What should you check if variables are not rendering correctly in a template?
Ensure the variables are passed in the context
Check for typos in the template variable names
Confirm the view is using the correct template
All of these
Q58
Q58 What is the primary purpose of Django's ORM?
To manage static files
To map Python objects to database tables
To handle form submissions
To manage URL routing
Q59
Q59 Which class do you inherit from to create a new model in Django?
django.Model
Model
django.db.Model
models.Model
Q60
Q60 What is the role of the Meta class in a Django model?
To define database fields
To define model metadata
To handle form validation
To manage URL patterns