5. You want to display a list of books stored in the database on a webpage. Which sequence correctly follows the MTV pattern in Django?
hard
A. View defines Book data, Template fetches books, Model displays books
B. Template fetches books, Model displays them, View handles user input
C. Model defines Book data, View fetches books and passes to Template, Template displays books
D. Model displays books, View defines data, Template fetches books
Solution
Step 1: Identify roles in MTV
Model handles data structure and database, View handles logic and data fetching, Template handles display.
Step 2: Match sequence to roles
Model defines Book data, View fetches books and passes to Template, Template displays books correctly orders Model for data, View for fetching and passing, Template for display.
Final Answer:
Model defines Book data, View fetches books and passes to Template, Template displays books -> Option C