mirror of
https://github.com/zulip/zulip.git
synced 2025-11-12 18:06:44 +00:00
ModelReprMixin: Fix handling of missing __unicode__ function.
The old behavior was to raise an exception, but Django was catching the exception and doing unexpected things. For instance, in the manage.py shell, printing out a ModelReprMixin object (with __unicode__ not implemented) would result in nothing being printed, rather than it raising a error or otherwise alerting the programmer as to what was going on.
This commit is contained in:
@@ -83,7 +83,9 @@ class ModelReprMixin(object):
|
||||
"""
|
||||
def __unicode__(self):
|
||||
# type: () -> text_type
|
||||
raise NotImplementedError("__unicode__ is not implemented in subclass of ModelReprMixin")
|
||||
# Originally raised an exception, but Django (e.g. the ./manage.py shell)
|
||||
# was catching the exception and not displaying any sort of error
|
||||
return u"Implement __unicode__ in your subclass of ModelReprMixin!"
|
||||
|
||||
def __str__(self):
|
||||
# type: () -> str
|
||||
|
||||
Reference in New Issue
Block a user