Sample questions
Question 1Easy
What does python manage.py startapp blog create?
- A new database named blog, created in the project folder with default tables
- A virtual environment
- An app package with models.py, views.py, admin.py and more
- A copy of the whole project
Answer: C. An app package with models.py, views.py, admin.py and more
Explanation
An app is a self-contained module; you must add it to INSTALLED_APPS afterwards.
Step-by-step solution
- Run startapp.
- Add to INSTALLED_APPS.
Why the other options are wrong
- A. The database is configured in settings.
- B. Virtualenv is separate.
- D. It creates one app folder only.
Question 2Easy
In Django's MTV pattern, which layer handles request logic and returns a response?
- Model
- View
- Template
- Manager
Answer: B. View
Explanation
The view receives the request, uses models, and returns a response, often rendering a template.
Step-by-step solution
- Request arrives.
- View runs logic.
- Response is returned.
Why the other options are wrong
- A. Model defines data and database access.
- C. Template defines presentation.
- D. A manager is part of the model layer.
Question 3Easy
In Django's MTV pattern, which component corresponds to the 'Controller' of classic MVC?
- The view, with the URLconf
- The model, which maps to the database
- The template, which renders the HTML
- The settings module, which wires apps
Answer: A. The view, with the URLconf
Explanation
A Django view holds the request-handling logic, and the URLconf routes requests to it.
Step-by-step solution
- In classic MVC, the Controller receives requests and decides what to do.
- In Django, the view holds that request-handling logic.
- The URLconf routes each URL to the right view.
- So the view, with the URLconf, is the answer: option A.
Why the other options are wrong
- B. The model maps to the database; it is the Model in MVC, not the Controller.
- C. The template renders HTML; it is the View in MVC.
- D. Settings hold configuration; they do not handle requests.
Tip: Django MTV mapping: Model is the MVC Model, Template is the MVC View, View is the MVC Controller.
Question 4Easy
In Django's MTV pattern, what does the 'T' stand for and do?
- Test: runs the unit tests for the project
- Transaction: manages database commits safely
- Token: handles authentication of the user
- Template: presents data as HTML
Answer: D. Template: presents data as HTML
Explanation
Templates define presentation.
Step-by-step solution
- MTV stands for Model, Template and View.
- The T is the Template.
- A template defines how data is presented as HTML.
- So the answer is option D: Template, which presents data as HTML.
Why the other options are wrong
- A. Testing is not part of the MTV name.
- B. Transactions are a database concept, not the T in MTV.
- C. Token handling is authentication, not the T in MTV.
Tip: MTV: Model holds the data, Template shows it, View decides what to send.
Question 5Easy
Which file in a project created by django-admin startproject is the command-line utility for running the dev server and migrations?
- settings.py
- urls.py
- manage.py
- wsgi.py
Answer: C. manage.py
Explanation
manage.py wraps django-admin and sets DJANGO_SETTINGS_MODULE.
Step-by-step solution
- Startproject creates settings.py, urls.py, wsgi.py and manage.py.
- manage.py is the command-line tool for the dev server, migrations and other commands.
- settings.py holds configuration, urls.py holds routes, wsgi.py is the server entry point.
- So the answer is manage.py: option C.
Why the other options are wrong
- A. settings.py holds configuration, not the command-line tool.
- B. urls.py maps URLs to views; it does not run commands.
- D. wsgi.py is the entry point for WSGI servers, not a command-line utility.
Tip: Project commands always go through manage.py; python manage.py help lists them.
Question 6Easy
Which command starts Django's development server?
- python manage.py runserver
- python manage.py start
- python manage.py serve
- python manage.py run
Answer: A. python manage.py runserver
Explanation
runserver starts a lightweight dev server.
Step-by-step solution
- Django uses 'runserver' to start the development server.
- The command is 'python manage.py runserver'.
- This is the standard way to launch the server.
- Other options like 'start' or 'serve' are not valid commands.
- Final answer: python manage.py runserver.
Why the other options are wrong
- B. start is not a Django management command; runserver is the one that starts the dev server.
- C. serve is not a Django management command; the dev server starts with runserver.
- D. run is not a Django management command; use runserver to start the development server.
Tip: Remember 'runserver' for starting Django dev servers.
Question 7Medium
An app is created but its models are not picked up by migrations. What is the usual missing step?
- Adding it to the MIDDLEWARE list in settings
- Adding it to INSTALLED_APPS
- Registering its models inside urls.py
- Running collectstatic for the new app
Answer: B. Adding it to INSTALLED_APPS
Explanation
Django only discovers models for apps listed in INSTALLED_APPS.
Step-by-step solution
- Django only discovers models in apps listed in INSTALLED_APPS.
- An app missing from that list is skipped, so its models never reach migrations.
- Adding the app to INSTALLED_APPS, then running makemigrations, fixes it.
- So the answer is option B: INSTALLED_APPS.
Why the other options are wrong
- A. MIDDLEWARE handles request and response processing, not model discovery.
- C. URLs do not register models.
- D. Collectstatic copies static files; it does not affect migrations.
Tip: If a new model gets no migration, check INSTALLED_APPS first.
Question 8Medium
Which file is the entry point for command-line utilities like runserver and migrate?
- manage.py
- wsgi.py
- settings.py
- urls.py
Answer: A. manage.py
Explanation
manage.py sets DJANGO_SETTINGS_MODULE and runs management commands.
Step-by-step solution
- Run manage.py command.
- Settings loaded.
Why the other options are wrong
- B. wsgi.py is for web servers.
- C. settings holds configuration.
- D. urls.py maps URLs.
Question 9Medium
Why must a new app be listed in INSTALLED_APPS?
- So the development server restarts automatically whenever the app's files change
- So URLs are auto created
- So the app is deployed
- So Django finds its models, templates, static files and migrations
Answer: D. So Django finds its models, templates, static files and migrations
Explanation
Many Django features discover things per installed app, such as model migrations and app templates.
Step-by-step solution
- Add dotted path.
- Discovery works.
Why the other options are wrong
- A. Reloading is unrelated.
- B. URLs need urls.py includes.
- C. Deployment is separate.
Question 10Hard
Which statement about wsgi.py and asgi.py is correct?
- They define the database schema and are edited whenever a model gets a new field
- They expose the application callable that production servers use to talk to Django
- They hold template filters
- They run migrations on startup
Answer: B. They expose the application callable that production servers use to talk to Django
Explanation
WSGI is the sync interface (Gunicorn); ASGI supports async features (Uvicorn, Daphne).
Step-by-step solution
- Server imports callable.
- Requests flow to Django.
Why the other options are wrong
- A. Models define schema.
- C. Templatetags hold filters.
- D. Migrations are run explicitly.
Practise all 11 questions free
The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.
Open this topic in the app →