Skip to content

Commit

Permalink
Sort detailed registrations by creation date in descending order
Browse files Browse the repository at this point in the history
  • Loading branch information
remyvdwereld committed Dec 31, 2024
1 parent 15909fc commit 5603244
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/apps/addresses/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,13 @@ def registrations(self, request, bag_id):
except Exception as e:
print(f"Error fetching details for {registration_number}: {e}")

# Sort detailed_registrations by 'createdAt' with the newest first
detailed_registrations = sorted(
detailed_registrations,
key=lambda x: x.get("createdAt", ""),
reverse=True,
)

serializer = RegistrationDetailsSerializer(
detailed_registrations, many=True
)
Expand Down

0 comments on commit 5603244

Please sign in to comment.