Community structure has a more intuitive, physical meaning than how it has traditionally been perceived; this representation plays an important role in networks and is accordingly becoming widely adapted. Consequently, community detection has attracted increasing attention. Although scholars have proposed many community detection methods from different perspectives, due to the complexity, diversity and dynamic characteristics of networks, efficient community detection in many real networks remains a challenge. Inspired by fish school effect in real life, this paper envisions networks as an ecosystem and proposes a novel dynamic model that aims to reveal the communities in a more intuitive way. Relying on the new model, we design a community detection algorithm, known as community detection based on fish school effect (CDFSE). CDFSE has plentiful desirable properties: high-quality community detection, parameters free and notable scalability. To evaluate the performance of CDFSE, this paper employs two widely utilized evaluation metrics and eleven representative algorithms to test the effectiveness of the algorithm in both synthetic and real-world networks. The experimental results show that in most cases, CDFSE is superior to the comparison methods in terms of the quality of community detection.