0👍
You have to use exists query which is faster then retrieve a row.
is_exists_room = Rooms.objects.filter(building_id=building_id, room_no=room_no).exists()
if not is_exists_room:
print("The room doesn't exist!")
Source:stackexchange.com
0👍
You have to use exists query which is faster then retrieve a row.
is_exists_room = Rooms.objects.filter(building_id=building_id, room_no=room_no).exists()
if not is_exists_room:
print("The room doesn't exist!")