2👍
✅
You can do it in one query with a join:
Visit.objects.get(room_id=room_id, journey__user_id=user_id)
Whether that’s actually faster will depend on your database; you should profile.
Source:stackexchange.com