Lesson 60 of 60 – Django Final Quiz
100%

Django Final Quiz

Congratulations! You have completed the Django tutorial. This final quiz will help you revise the important concepts covered throughout the course.

Note: Read each question carefully and choose the best answer. The quiz covers Django fundamentals, URLs, views, templates, models, ORM, forms, authentication, file handling, pagination, CRUD, projects, and REST APIs.

1. What is Django?

Django is a:

  • Python web framework
  • Database management system
  • Programming language
  • Operating system

Answer: Python web framework

2. Which language is primarily used with Django?

Django is primarily built for:

  • Python
  • Java
  • C#
  • PHP

Answer: Python

3. Which command creates a Django project?

django-admin startproject myproject

The startproject command creates the initial Django project structure.

Answer: django-admin startproject

4. Which file contains Django project settings?

The main configuration settings are stored in:

settings.py

It contains settings such as INSTALLED_APPS, DATABASES, MIDDLEWARE, and STATIC_URL.

Answer: settings.py

5. Which command starts the Django development server?

python manage.py runserver

This command starts Django's development server.

Answer: python manage.py runserver

6. Which file normally contains URL patterns?

Django URL patterns are normally defined in:

urls.py

The urlpatterns list contains URL routes.

Answer: urls.py

7. Which function is commonly used to connect a URL to a view?

path()

The path() function is commonly used to define URL routes.

Answer: path()

8. What is the main purpose of a Django view?

A view processes a request and returns a response.

def home(request):
    return render(
        request,
        "home.html"
    )

Answer: Handle requests and return responses

9. Which function is commonly used to render a template?

render()

The render() function combines a request, template, and context data to produce a response.

Answer: render()

10. Which syntax is used for Django template variables?

{{ name }}

Double curly braces are used to display template variables.

Answer: {{ variable }}

11. Which syntax is used for Django template tags?

{% if user %}
    Welcome
{% endif %}

Django template tags use {% and %}.

Answer: {% %}

12. Which tag is used for template inheritance?

{% extends "base.html" %}

The extends tag allows a child template to inherit from a base template.

Answer: {% extends %}

13. Which file normally contains model definitions?

models.py

Django models describe the structure of database data.

Answer: models.py

14. Which Django component provides database abstraction?

Django's Object-Relational Mapper provides an interface for working with database records using Python objects and QuerySets.

Answer: Django ORM

15. Which command creates migration files?

python manage.py makemigrations

This command detects model changes and creates migration files.

Answer: makemigrations

16. Which command applies migrations to the database?

python manage.py migrate

The migrate command applies migration operations to the database.

Answer: migrate

17. Which command creates an administrator account?

python manage.py createsuperuser

This command creates a user who can access the Django admin site.

Answer: createsuperuser

18. Which ORM query retrieves all Student records?

Student.objects.all()

The all() method returns a QuerySet containing all records from the model.

Answer: Student.objects.all()

19. Which ORM method is commonly used to filter records?

Student.objects.filter(
    course="Python"
)

The filter() method returns records matching the specified conditions.

Answer: filter()

20. Which field creates a many-to-one relationship?

Django uses:

ForeignKey

A ForeignKey is commonly used when many records can belong to one related record.

Answer: ForeignKey

21. Which field creates a one-to-one relationship?

OneToOneField

A OneToOneField represents a one-to-one relationship between models.

Answer: OneToOneField

22. Which field represents a many-to-many relationship?

ManyToManyField

ManyToManyField allows multiple records on both sides of a relationship.

Answer: ManyToManyField

23. Which class is used to create a ModelForm?

forms.ModelForm

ModelForm can generate form fields based on a Django model.

Answer: forms.ModelForm

24. Which method checks whether a form is valid?

form.is_valid()

The is_valid() method runs the form's validation process.

Answer: form.is_valid()

25. Which function authenticates a user's credentials?

authenticate()

The authenticate() function checks the supplied credentials against Django's authentication system.

Answer: authenticate()

26. Which function logs a user into a Django session?

login(request, user)

The login() function associates the authenticated user with the current session.

Answer: login()

27. Which object is used to access uploaded files?

request.FILES

Uploaded files from a multipart form request are available through request.FILES.

Answer: request.FILES

28. Which Django class is commonly used for pagination?

from django.core.paginator import Paginator

The Paginator class divides a collection into pages.

Answer: Paginator

29. Which package is commonly used to build REST APIs with Django?

Django REST Framework

Django REST Framework provides tools such as serializers, API views, authentication, permissions, and routers for building APIs.

Answer: Django REST Framework

30. What is the overall Django development flow?

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

📌 Django Course Completed!

  • You learned Django fundamentals.
  • You learned project and application structure.
  • You learned URLs and views.
  • You learned templates and template inheritance.
  • You learned static and media files.
  • You learned models and migrations.
  • You learned Django ORM and QuerySets.
  • You learned CRUD operations.
  • You learned model relationships.
  • You learned forms and ModelForms.
  • You learned authentication and sessions.
  • You learned file and image uploads.
  • You learned pagination and search.
  • You built practical CRUD and management projects.
  • You learned the basics of Django REST APIs.
  • You are now ready to build complete Django applications.

🧠 Final Quiz

Question: Which Django component is primarily responsible for handling a web request and returning a response?