Speed up sql
This commit is contained in:
parent
fdf5ab8ad1
commit
81a0959547
4 changed files with 18 additions and 12 deletions
|
@ -24,7 +24,7 @@ class BasicItemSerializer(serializers.ModelSerializer):
|
|||
|
||||
def get_file(self, instance):
|
||||
if len(instance.files.all()) > 0:
|
||||
return instance.files.all().order_by('-created_at')[0].hash
|
||||
return sorted(instance.files.all(), key=lambda x: x.created_at, reverse=True)[0].hash
|
||||
return None
|
||||
|
||||
def get_returned(self, instance):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue