Congratulations! You have completed the Django tutorial. This final quiz will help you revise the important concepts covered throughout the course.
Django is a:
Answer: Python web framework
Django is primarily built for:
Answer: Python
django-admin startproject myproject
The startproject command creates the initial Django project
structure.
Answer: django-admin startproject
The main configuration settings are stored in:
settings.py
It contains settings such as INSTALLED_APPS,
DATABASES, MIDDLEWARE, and
STATIC_URL.
Answer: settings.py
python manage.py runserver
This command starts Django's development server.
Answer: python manage.py runserver
Django URL patterns are normally defined in:
urls.py
The urlpatterns list contains URL routes.
Answer: urls.py
path()
The path() function is commonly used to define URL routes.
Answer: path()
A view processes a request and returns a response.
def home(request):
return render(
request,
"home.html"
)
Answer: Handle requests and return responses
render()
The render() function combines a request, template, and
context data to produce a response.
Answer: render()
{{ name }}
Double curly braces are used to display template variables.
Answer: {{ variable }}
{% if user %}
Welcome
{% endif %}
Django template tags use {% and %}.
Answer: {% %}
{% extends "base.html" %}
The extends tag allows a child template to inherit from a
base template.
Answer: {% extends %}
models.py
Django models describe the structure of database data.
Answer: models.py
Django's Object-Relational Mapper provides an interface for working with database records using Python objects and QuerySets.
Answer: Django ORM
python manage.py makemigrations
This command detects model changes and creates migration files.
Answer: makemigrations
python manage.py migrate
The migrate command applies migration operations to the
database.
Answer: migrate
python manage.py createsuperuser
This command creates a user who can access the Django admin site.
Answer: createsuperuser
Student.objects.all()
The all() method returns a QuerySet containing all records
from the model.
Answer: Student.objects.all()
Student.objects.filter(
course="Python"
)
The filter() method returns records matching the specified
conditions.
Answer: filter()
Django uses:
ForeignKey
A ForeignKey is commonly used when many records can belong to one related record.
Answer: ForeignKey
OneToOneField
A OneToOneField represents a one-to-one relationship between models.
Answer: OneToOneField
ManyToManyField
ManyToManyField allows multiple records on both sides of a relationship.
Answer: ManyToManyField
forms.ModelForm
ModelForm can generate form fields based on a Django model.
Answer: forms.ModelForm
form.is_valid()
The is_valid() method runs the form's validation process.
Answer: form.is_valid()
authenticate()
The authenticate() function checks the supplied credentials
against Django's authentication system.
Answer: authenticate()
login(request, user)
The login() function associates the authenticated user with
the current session.
Answer: login()
request.FILES
Uploaded files from a multipart form request are available through
request.FILES.
Answer: request.FILES
from django.core.paginator import Paginator
The Paginator class divides a collection into pages.
Answer: Paginator
Django REST Framework
Django REST Framework provides tools such as serializers, API views, authentication, permissions, and routers for building APIs.
Answer: Django REST Framework
A common Django application flow is:
Browser
↓
URL
↓
View
↓
Model / Form / ORM
↓
Database
↓
View
↓
Template
↓
Response
↓
Browser
Understanding this flow helps connect the major concepts learned in the Django tutorial.
Answer: URL → View → Model/Form/ORM → Database → Template → Response
Question: Which Django component is primarily responsible for handling a web request and returning a response?