Temperature has a significant effect on all physiological processes of animals. Suitable temperatures promote responsiveness, movement, metabolism, growth, and reproduction in animals, whereas extreme temperatures can cause injury or even death. Thus, thermosensation is important for survival in all animals. However, mechanisms regulating thermosensation remain unexplored, mostly because of the complexity of mammalian neural circuits. The fruit fly Drosophila melanogaster achieves a desirable body temperature through ambient temperature fluctuations, sunlight exposure, and behavioral strategies. The availability of extensive genetic tools and resources for studying Drosophila have enabled scientists to unravel the mechanisms underlying their temperature preference. Over the past 20 years, Drosophila has become an ideal model for studying temperature-related genes and circuits. This review provides a comprehensive overview of our current understanding of thermosensation and temperature preference in Drosophila. It encompasses various aspects, such as the mechanisms by which flies sense temperature, the effects of internal and external factors on temperature preference, and the adaptive strategies employed by flies in extreme-temperature environments. Understanding the regulating mechanisms of thermosensation and temperature preference in Drosophila can provide fundamental insights into the underlying molecular and neural mechanisms that control body temperature and temperature-related behavioral changes in other animals.