From adc8dc83dead1afcc9ff83ae7a0f57747a886a4b Mon Sep 17 00:00:00 2001 From: Johannes Christ Date: Fri, 21 Sep 2018 23:09:35 +0200 Subject: Add `__str__` to all API models. --- api/models.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'api/models.py') diff --git a/api/models.py b/api/models.py index c04984fa..6b681ebc 100644 --- a/api/models.py +++ b/api/models.py @@ -41,6 +41,9 @@ class DocumentationLink(ModelReprMixin, models.Model): help_text="The URL at which the Sphinx inventory is available for this package." ) + def __str__(self): + return f"{self.package} - {self.base_url}" + class OffTopicChannelName(ModelReprMixin, models.Model): name = models.CharField( @@ -50,6 +53,9 @@ class OffTopicChannelName(ModelReprMixin, models.Model): help_text="The actual channel name that will be used on our Discord server." ) + def __str__(self): + return self.name + class SnakeName(ModelReprMixin, models.Model): """A snake name used by the bot's snake cog.""" @@ -64,6 +70,9 @@ class SnakeName(ModelReprMixin, models.Model): help_text="The scientific name for this snake, e.g. 'Python bivittatus'." ) + def __str__(self): + return f"{self.name} ({self.scientific})" + class Role(ModelReprMixin, models.Model): """A role on our Discord server.""" @@ -105,6 +114,9 @@ class Role(ModelReprMixin, models.Model): help_text="The integer value of the permission bitset of this role from Discord." ) + def __str__(self): + return self.name + class Member(ModelReprMixin, models.Model): """A member of our Discord server.""" @@ -144,3 +156,6 @@ class Member(ModelReprMixin, models.Model): Role, help_text="Any roles this user has on our server." ) + + def __str__(self): + return f"{self.name}#{self.discriminator}" -- cgit v1.2.3