Fero.ai interview question

Write django ORM query for periculat problem and optimize it.