Django MCQ Questions & Answers
Django MCQs : This section focuses on "Django" of Python Frameworks. These Multiple Choice Questions (MCQ) should be practiced to improve the Django skills required for various interviews (campus interviews, walk-in interviews, company interviews), placements, entrance exams and other competitive examinations.
1. Django is a _____________ Python web framework.
A. low-level
B. mid-level
C. high-level
D. None of the above
View Answer
Ans : C
Explanation: Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design.
2. Django was created in the fall of?
A. 2001
B. 2003
C. 2005
D. 2007
View Answer
Ans : B
Explanation: 2003 : Started by Adrian Holovaty and Simon Willison as an internal project at the Lawrence Journal-World newspaper.
3. Which of the following are Advantages of Django?
A. Object-Relational Mapping (ORM) Support
B. Multilingual Support
C. Administration GUI
D. Framework Support
View Answer
Ans : D
Explanation: All of the above are advantages of using Django.
4. Django supports the ___________ pattern.
A. MVI
B. MVP
C. MVC
D. MVZ
View Answer
Ans : C
Explanation: Django supports the MVC pattern.
5. MVC pattern is based on _______ components.
A. 2
B. 3
C. 4
D. 5
View Answer
Ans : B
Explanation: MVC pattern is based on three components: Model, View, and Controller.
6. MVT Stands for?
A. Model-View-Template
B. Model-View-Table
C. Map-View-Template
D. Main-View-Template
View Answer
Ans : A
Explanation: The Model-View-Template (MVT) is slightly different from MVC. The template is a HTML file mixed with Django Template Language (DTL).
7. Which commands use to create a project in Django?
A. $ django-admin createproject project_name
B. $ django-admin startproject project_name
C. $ django startproject project_name
D. $ django createproject project_name
View Answer
Ans : C
Explanation: Whether you are on Windows or Linux, just get a terminal or a cmd prompt and navigate to the place you want your project to be created, then use this code : $ django-admin startproject project_name.
8. Which file is kind of your project local django-admin for interacting with your project via command line?
A. settings.py
B. admin.py
C. models.py
D. manage.py
View Answer
Ans : D
Explanation: manage.py : This file is kind of your project local django-admin for interacting with your project via command line (start the development server, sync db...).
9. Which of the following is used If you need to deploy your project over WSGI?
A. settings.py
B. wsgi.py
C. urls.py
D. __init__.py
View Answer
Ans : B
Explanation: wsgi.py is used if you need to deploy your project over WSGI.
10. View response can be the ?
A. HTML contents
B. 404 error
C. XML document
D. All of the above
View Answer
Ans : D
Explanation: View response can be the HTML contents of a Web page, or a redirect, or a 404 error, or an XML document, or an image.
11. In Django, views have to be created in the app views.py file.
A. TRUE
B. FALSE
C. Can be true or false
D. Can not say
View Answer
Ans : A
Explanation: True, In Django, views have to be created in the app views.py file.
12. Render function takes ___________ parameters.
A. 1
B. 2
C. 3
D. 4
View Answer
Ans : C
Explanation: This function takes three parameters : Request, The path to the template and Dictionary of parameters.
13. A variable in django looks like this: _________________.
A. ((variable))
B. {{variable}}
C. [[variable]]
D. [{variable}]
View Answer
Ans : B
Explanation: Displaying Variables : A variable looks like this: {{variable}}
14. Which filter will truncate the string, so you will see only the first 80 words?
A. {{string|truncatewords}}
B. {{string|truncate:80}}
C. {{string|truncate}}
D. {{string|truncatewords:80}}
View Answer
Ans : D
Explanation: {{string|truncatewords:80}} : This filter will truncate the string, so you will see only the first 80 words.
15. How many kinds of HTTP requests there in Django?
A. 2
B. 3
C. 4
D. 5
View Answer
Ans : A
Explanation: There are two kinds of HTTP requests, GET and POST.
16. Suppose you want to count the number of books in Django.Which implementation would be fastest?
books = Book.objects.all()
A. Template Language Implementation – {{ books | length }}
B. Python Implementation – len(books)
C. Database level Implementation – books.count()
D. None of the above
View Answer
Ans : C
Explanation: Database level Implementation – books.count() implementation would be fastest.
17. Which of these variables are the settings for django.contib.staticfiles app?
A. STATIC_URL
B. STATIC_ROOT
C. STATICFILES_DIRS
D. All of the above
View Answer
Ans : D
Explanation: All of the above are variables are the settings for django.contib.staticfiles app.
18. What are some valid forloop attributes of Django Template System?
A. forloop.lastitem
B. forloop.counter
C. forloop.firstitem
D. forloop.reverse
View Answer
Ans : B
Explanation: forloop.counter valid forloop attributes of Django Template System.
19. Django Comments framework is deprecated, since the 1.5 version.
A. TRUE
B. FALSE
C. Can be true or false
D. Can not say
View Answer
Ans : A
Explanation: True, Django Comments framework is deprecated, since the 1.5 version.
20. Which of these is not a valid method or approach to perform URL resolution?
A. Using Template {{ url : }} in template
B. Using reverse() in View Functions
C. Using get_absolute_url()
D. None of the above
View Answer
Ans : D
Explanation: None of the above is not a valid method or approach to perform URL resolution.
Discussion