models: Remove type prefixes from __str__ values.

The Django convention is for __repr__ to include the type and __str__
to omit it.  In fact its default __repr__ implementation for models
automatically adds a type prefix to __str__, which has resulted in the
type being duplicated:

    >>> UserProfile.objects.first()
    <UserProfile: <UserProfile: emailgateway@zulip.com <Realm: zulipinternal 1>>>

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2023-03-08 13:18:59 -08:00
committed by Anders Kaseorg
parent f66136fcc2
commit 2d9b2a2a05
18 changed files with 80 additions and 82 deletions

View File

@@ -1645,9 +1645,9 @@ class StreamMessagesTest(ZulipTestCase):
self.send_stream_message(sender, "Denmark", content="whatever", topic_name="my topic")
message = most_recent_message(receiving_user_profile)
self.assertEqual(
str(message),
repr(message),
"<Message: Denmark / my topic / "
"<UserProfile: {} {}>>".format(sender.email, sender.realm),
"<UserProfile: {} {!r}>>".format(sender.email, sender.realm),
)
def test_message_mentions(self) -> None: