update prefetched fields
This commit is contained in:
parent
c03d298a58
commit
ec6e872163
4 changed files with 23 additions and 7 deletions
|
@ -32,7 +32,11 @@ class Item(SoftDeleteModel):
|
|||
@property
|
||||
def container(self):
|
||||
try:
|
||||
return self.container_history.order_by('-timestamp').first().container
|
||||
history = sorted(self.container_history.all(), key=lambda x: x.timestamp, reverse=True)
|
||||
if history:
|
||||
return history[0].container
|
||||
else:
|
||||
return None
|
||||
except AttributeError:
|
||||
return None
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue