Q. What is the use of `__str__()` method in Django models?

  • (A) To return a JSON representation
  • (B) To return a string representation
  • (C) To return object memory address
  • (D) To return HTML output
πŸ’¬ Discuss
βœ… Correct Answer: (B) To return a string representation
Explanation: `__str__()` defines how the object is represented as a string.
Explanation by: Mr. Dubey
`__str__()` defines how the object is represented as a string.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
84
Total Visits
πŸ“½οΈ
1 y ago
Published
πŸŽ–οΈ
Mr. Dubey
Publisher
πŸ“ˆ
88%
Success Rate