Unit 1: Introduction to Django - Practice Quiz

INT253 — Web Development In Python Using Django 60 Questions
0 Correct 0 Wrong 60 Left
0/60

1 What is Django?

Introduction to Django Easy
A. A Python web framework
B. A desktop operating system
C. A database management system
D. A JavaScript testing library

2 Which programming language is primarily used with Django?

Introduction to Django Easy
A. Java
B. Python
C. PHP
D. C++

3 Which architectural pattern does Django commonly follow?

Introduction to Django Easy
A. Data-Logic-Screen
B. Client-Server-Database
C. Model-Page-Control
D. Model-View-Template

4 Which command is commonly used to install Django with pip?

Installing Python and Django Easy
A. pip create django
B. django setup pip
C. pip install django
D. python install django

5 Which command can display the installed Python version?

Installing Python and Django Easy
A. python --django
B. python --start
C. python --version
D. python --install

6 Which editor feature helps developers run Django commands without leaving the editor?

Setting up project in editor Easy
A. Color picker
B. Integrated terminal
C. Image preview
D. Spell checker

7 What should normally be opened as the workspace folder in a code editor?

Setting up project in editor Easy
A. The Django project folder
B. The browser cache folder
C. The Python download page
D. The operating system folder

8 What does a Django project usually represent?

Projects and Apps overview Easy
A. A single database table definition
B. The complete web application configuration
C. A Python installation package
D. One HTML page in a browser

9 What is a Django app designed to provide?

Projects and Apps overview Easy
A. A complete operating system
B. A specific reusable feature
C. A web browser extension
D. A Python language compiler

10 Can one Django project contain multiple apps?

Projects and Apps overview Easy
A. No, it must contain one app
B. No, apps cannot join projects
C. Yes, it can contain multiple apps
D. Yes, but only during testing

11 Which Django project file contains settings such as installed apps and database configuration?

Project structure Easy
A. settings.py
B. tests.py
C. models.py
D. views.py

12 Which project file usually defines the main URL routes?

Project structure Easy
A. apps.py
B. urls.py
C. admin.py
D. models.py

13 What is the purpose of the wsgi.py file in a Django project?

Project structure Easy
A. It defines the application's database models
B. It lists the application's unit tests
C. It provides a WSGI deployment entry point
D. It stores the project's HTML templates

14 Which command creates a Django project named mysite?

Creating your first project Easy
A. django-admin migrate mysite
B. django-admin runserver mysite
C. django-admin startproject mysite
D. django-admin startapp mysite

15 Which command starts Django's development server?

Django-admin and manage.py commands Easy
A. python manage.py shellserver
B. python manage.py runserver
C. python manage.py collectapp
D. python manage.py startproject

16 What is manage.py mainly used for?

Django-admin and manage.py commands Easy
A. Installing the Python programming language
B. Running project-specific Django commands
C. Writing HTML styles for templates
D. Creating tables without Django models

17 Which command applies pending database migrations?

Django-admin and manage.py commands Easy
A. python manage.py runserver
B. python manage.py testserver
C. python manage.py migrate
D. python manage.py startapp

18 Which file in a Django app is commonly used to define database models?

App structures Easy
A. views.py
B. models.py
C. admin.py
D. apps.py

19 Which file in a Django app commonly contains request-handling functions or classes?

App structures Easy
A. tests.py
B. apps.py
C. models.py
D. views.py

20 Which command creates a Django app named blog?

Creating an App Easy
A. python manage.py runapp blog
B. python manage.py startproject blog
C. python manage.py startapp blog
D. python manage.py migrate blog

21 A team must quickly build a database-backed employee portal with authentication and an administrative interface. Why is Django a suitable choice?

Introduction to Django Medium
A. It automatically generates a mobile application from Python code
B. It provides an ORM, authentication, and an admin interface
C. It is designed only for static websites that do not use databases or server-side processing
D. It runs entirely in the browser without a web server

22 Which sequence correctly installs Django in an isolated environment for a new project?

Installing Python and Django Medium
A. Download Django source files manually, copy them into Python's standard library, and restart the operating system
B. Create a Django app, activate manage.py, and install the editor
C. Create a virtual environment, activate it, and run pip install django
D. Install Django globally, create a project, and then create Python

23 A computer has several Python installations. Which command most reliably checks the Django version available to the Python interpreter currently being used?

Installing Python and Django Medium
A. pip create django --version
B. python manage.py install django
C. python -m django --version
D. django-admin startproject --version

24 Django runs correctly from an activated virtual environment, but the editor reports that django imports cannot be resolved. What should be checked first?

Setting up project in editor Medium
A. The project's templates have been placed inside the settings package
B. The development server has been configured to use a different port number
C. Every Django package has been copied manually into the editor's extension directory so code completion can detect it
D. The editor is using the virtual environment's Python interpreter

25 An online store needs separate functionality for products, customer accounts, and payments. Which Django organization is most appropriate?

Projects and Apps overview Medium
A. Three projects containing one shared settings file and one shared server
B. One app containing three separate manage.py files for each feature
C. Three virtual environments placed inside a single app package
D. One project containing separate products, accounts, and payments apps

26 A reviews component may be reused in a bookstore site and a movie site. Which design best supports this goal?

Projects and Apps overview Medium
A. Place review models directly in each project's settings.py file
B. Store all review logic in manage.py so every Django project can execute it without installing an app
C. Keep reviews in a focused app with limited project-specific dependencies
D. Combine reviews with every other feature in one large application

27 After running django-admin startproject portal, which file should be edited to add an installed app and configure a database?

Project structure Medium
A. portal/manage.py
B. portal/portal/asgi.py
C. portal/portal/urls.py
D. portal/portal/settings.py

28 A developer wants requests beginning with /blog/ to be handled by the blog app. Which project file normally contains the top-level URL mapping?

Project structure Medium
A. project_package/urls.py
B. blog/admin.py
C. project_package/settings.py
D. blog/models.py

29 A deployment platform requires an ASGI callable for an asynchronous-compatible deployment. Which generated file exposes the appropriate application object?

Project structure Medium
A. settings.py
B. asgi.py
C. manage.py, after rewriting it to create and operate a permanent asynchronous production server
D. wsgi.py

30 A developer is already inside an empty directory named schoolsite and wants manage.py created directly in that directory without another nested outer folder. Which command should be used?

Creating your first project Medium
A. python manage.py startproject config
B. django-admin startapp config .
C. django-admin startproject config
D. django-admin startproject config .

31 Which command starts Django's development server on local port 8080?

Django-admin and manage.py commands Medium
A. python manage.py runserver, followed by editing settings.py to permanently replace Django's default port
B. python manage.py runserver 8080
C. django-admin runserver --port 8080
D. python manage.py startserver 8080

32 The initial Django project contains migration files for built-in apps, but their database tables do not yet exist. Which command applies them?

Django-admin and manage.py commands Medium
A. python manage.py migrate
B. python manage.py collectstatic
C. python manage.py inspectdb
D. python manage.py makemigrations

33 Why is python manage.py <command> commonly used after a Django project has been created instead of django-admin <command>?

Django-admin and manage.py commands Medium
A. manage.py replaces the need for a Python interpreter
B. manage.py converts every command into a database migration and applies it before the requested operation begins
C. manage.py automatically points commands to the project's settings
D. manage.py installs missing dependencies before every command

34 A developer wants Django to detect common configuration problems without starting the server or modifying the database. Which command is most appropriate?

Django-admin and manage.py commands Medium
A. python manage.py shell
B. python manage.py testserver
C. python manage.py check
D. python manage.py migrate

35 A developer is adding a database-backed Article entity to a newly created app. In which file should the model class normally be defined?

App structures Medium
A. admin.py
B. apps.py
C. models.py
D. views.py

36 A Product model already exists, and the developer wants it to appear in Django's administration interface. Which app file is normally updated to register it?

App structures Medium
A. admin.py
B. migrations/__init__.py, where all administration registrations and generated schema changes should be combined
C. apps.py
D. tests.py

37 What is the primary purpose of the migrations directory inside a Django app?

App structures Medium
A. It stores versioned descriptions of database schema changes
B. It stores copies of every model object so the database can be restored automatically whenever the server starts
C. It stores HTML templates generated from database records
D. It stores production server configuration for the application

38 From the directory containing manage.py, which command correctly creates an app named inventory?

Creating an App Medium
A. django-admin createapp inventory
B. python manage.py startapp inventory
C. python inventory manage.py startapp
D. python manage.py startproject inventory

39 An app named inventory has been created, but Django does not detect its models when makemigrations is run. What is the most likely missing step?

Creating an App Medium
A. Add inventory or its app configuration to INSTALLED_APPS
B. Move manage.py into the inventory app directory
C. Rename the app's models.py file to database.py
D. Add the app to MIDDLEWARE so Django loads its models before processing every incoming HTTP request

40 A developer creates a blog app and defines views in it, but visiting /blog/ still produces a 404 response. Which integration step is required?

Creating an App Medium
A. Connect a URL pattern to the app's views through the URL configuration
B. Run startapp blog again after the development server has started
C. Delete the project URL configuration because Django discovers and exposes all app views automatically
D. Move the app's views into the project's settings.py module

41 A Django view retrieves records through the ORM, renders them with a template, and returns an HTTP response. Which mapping most accurately describes Django's MTV architecture in this request?

Introduction to Django Hard
A. Model handles presentation, Template routes requests, and View manages database schemas
B. Model creates responses, Template manages middleware, and View configures database connections
C. Model routes URLs, Template validates requests, and View stores persistent application data
D. Model manages data, Template handles presentation, and View coordinates request processing

42 Django was installed successfully with pip install django, but python -m django --version reports No module named django. Which diagnosis is most likely?

Installing Python and Django Hard
A. Django cannot be imported until a project has been created with startproject
B. pip installed Django for a different Python interpreter than the one invoked by python
C. The Django package is available only through django-admin, not as a Python module
D. Python prevents Django imports until DJANGO_SETTINGS_MODULE has been explicitly defined

43 A developer wants to guarantee that Django is installed into the currently activated virtual environment, even when multiple pip executables exist on PATH. Which command is the most reliable?

Installing Python and Django Hard
A. pip install Django --global
B. python -m pip install Django
C. django-admin install Django
D. python django-admin install

44 A Django project runs correctly from a terminal with its virtual environment activated, but the editor marks every django import as unresolved. What is the most appropriate correction?

Setting up project in editor Hard
A. Configure the editor to use the virtual environment's Python interpreter
B. Add the Django installation directory to every module's sys.path
C. Replace all Django imports with paths relative to manage.py
D. Copy Django's package directory into the project's source directory

45 A team is building an e-commerce site with independently reusable inventory, payment, and review functionality. Which design best follows Django's project-and-app model?

Projects and Apps overview Hard
A. Use one app containing separate projects for inventory, payment, and reviews
B. Use one project per model and combine them through a single manage.py file
C. Use three projects containing one shared application package and settings file
D. Use one project containing separate inventory, payment, and review apps

46 An app package exists inside a Django project and can be imported successfully, but Django does not discover its models during normal application loading. Which omission most directly explains this?

Projects and Apps overview Hard
A. The app or its AppConfig is absent from INSTALLED_APPS
B. The app's directory is not listed explicitly in the root URL configuration
C. The app has not been imported manually inside the project's manage.py
D. The app does not contain a second project-level settings.py module

47 After running django-admin startproject config, which file is intended primarily as the command-line entry point and normally sets DJANGO_SETTINGS_MODULE before delegating to Django?

Project structure Hard
A. config/urls.py
B. config/__init__.py
C. config/asgi.py
D. manage.py

48 A generated project's inner package is renamed from config to core, but no file contents are updated. Running python manage.py check now fails to import the settings module. Which reference must be updated to address this immediate failure?

Project structure Hard
A. DJANGO_SETTINGS_MODULE in manage.py from config.settings to core.settings
B. WSGI_APPLICATION in settings.py from config.wsgi to core.urls
C. BASE_DIR in settings.py from config to core
D. ROOT_URLCONF in settings.py from config.urls to core.settings

49 A developer is already inside an existing repository root and wants manage.py placed there while creating the project package as config/. Which command is appropriate?

Creating your first project Hard
A. python manage.py startproject config .
B. django-admin startapp config .
C. django-admin startproject config .
D. django-admin startproject . config

50 A directory already contains a file named manage.py. What should a developer expect when running django-admin startproject config . in that directory?

Creating your first project Hard
A. Django moves the existing file into the new config package
B. Django refuses to overwrite the conflicting file and reports an error
C. Django creates a second entry point named manage_1.py
D. Django silently replaces the existing file with the project template

51 Why does python manage.py check usually work without a --settings argument, while a directly invoked django-admin check may require settings configuration?

Django-admin and manage.py commands Hard
A. manage.py sets the project's default DJANGO_SETTINGS_MODULE before executing commands
B. django-admin supports only commands that do not depend on project settings
C. manage.py embeds all settings directly and never imports a settings module
D. django-admin searches exclusively for settings inside installed application packages

52 A project has config/settings/dev.py and config/settings/prod.py, and no usable default settings module. Which command explicitly runs system checks with the development settings?

Django-admin and manage.py commands Hard
A. python manage.py check --settings=config.settings.dev
B. python manage.py check --config=config.settings.dev
C. python manage.py check --settings=config/settings/dev.py
D. python manage.py --settings config.settings.dev check

53 A developer changes a model class and immediately runs python manage.py migrate, but no database alteration occurs. Assuming the app is installed correctly, which missing action best explains the result?

Django-admin and manage.py commands Hard
A. Run python manage.py makemigrations to generate a migration first
B. Run python manage.py check to translate the model directly into SQL
C. Run python manage.py collectstatic to register the changed schema
D. Run python manage.py startapp to rebuild the application's model registry

54 A development server must accept connections from other machines on the local network using port 9000. Which command requests the required binding?

Django-admin and manage.py commands Hard
A. python manage.py runserver 127.0.0.1:9000
B. python manage.py runserver 0.0.0.0:9000
C. python manage.py runserver localhost:9000
D. python manage.py runserver --public 9000

55 In a newly generated Django app, which file is specifically intended to define application metadata and startup configuration through a subclass of AppConfig?

App structures Hard
A. apps.py
B. admin.py
C. tests.py
D. models.py

56 A migration file imports migrations and defines dependencies and operations but is never detected by Django. The filename is valid and the app is installed. Which structural problem is most likely?

App structures Hard
A. The file is not imported manually from the app's models.py
B. The file is not registered through the app's admin.py module
C. The file is outside the app's migrations Python package
D. The file is missing a URL pattern in the project's urls.py

57 A developer runs python manage.py startapp reports, sees the new package, and then runs makemigrations reports. Django responds that no installed app has the label reports. What is the most likely cause?

Creating an App Hard
A. The generated app has not been included in ROOT_URLCONF
B. The generated app lacks its own project-level settings.py
C. The generated app was not added to INSTALLED_APPS
D. The generated app does not yet contain a root manage.py

58 An app is stored at company/modules/billing, and its AppConfig.name is company.modules.billing. Which INSTALLED_APPS entry most explicitly selects that configuration class?

Creating an App Hard
A. company.modules.billing.apps.BillingConfig
B. company.modules.billing.models.BillingConfig
C. company.modules.billing.BillingConfig
D. company.modules.billing.apps.Billing

59 A developer wants startapp to populate an already existing directory /srv/project/modules/audit. Which command has the correct argument structure?

Creating an App Hard
A. django-admin startapp /srv/project/modules/audit audit
B. django-admin startproject audit /srv/project/modules/audit
C. python manage.py createapp /srv/project/modules/audit audit
D. django-admin startapp audit /srv/project/modules/audit

60 A deployment server needs a synchronous WSGI callable, while another server needs an asynchronous ASGI callable. Which generated modules expose these interfaces by default?

Project structure Hard
A. asgi.py exposes application for WSGI, and wsgi.py exposes application for ASGI
B. wsgi.py exposes application for WSGI, and asgi.py exposes application for ASGI
C. manage.py exposes wsgi_application, and urls.py exposes asgi_application
D. settings.py exposes both callables directly through INSTALLED_APPS