Skip to content

Commit d9eb5dd

Browse files
committed
Do not cast objects when initializing their string representation
closes #3898 (cherry picked from commit 31b2b86)
1 parent 04851b4 commit d9eb5dd

File tree

2 files changed

+2
-12
lines changed

2 files changed

+2
-12
lines changed

CHANGES/3898.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed the method for displaying the representation of ``MasterModel`` objects.

pulpcore/app/models/base.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -197,18 +197,7 @@ def master(self):
197197

198198
def __str__(self):
199199
# similar to Model's __str__, but type-aware
200-
cast = self.cast()
201-
if cast is self:
202-
return super().__str__()
203-
204-
try:
205-
return "<{} (pulp_type={}): {}>".format(
206-
self._meta.object_name, cast.pulp_type, cast.name
207-
)
208-
except AttributeError:
209-
return "<{} (pulp_type={}): pk={}>".format(
210-
self._meta.object_name, cast.pulp_type, cast.pk
211-
)
200+
return "<{} (pulp_type={}): pk={}>".format(self._meta.object_name, self.pulp_type, self.pk)
212201

213202

214203
# Add properties to model _meta info to support master/detail models

0 commit comments

Comments
 (0)