Q. What does `__str__` method do in a Django model?

  • (A) Renders a model’s database table
  • (B) Returns model field count
  • (C) Returns a human-readable string for the model
  • (D) Validates the model
πŸ’¬ Discuss
βœ… Correct Answer: (C) Returns a human-readable string for the model
Explanation: `__str__` returns a string representation of the model, used in admin and shell.
Explanation by: Mr. Dubey
`__str__` returns a string representation of the model, used in admin and shell.

πŸ’¬ Discussion


πŸ“Š Question Analytics

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