Django MCQ Questions
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