Because of the highly nonlinear and dynamic spatial–temporal correlation of traffic flow, timely and accurate forecasting is very challenging. Existing methods usually use a static adjacency matrix to represent the spatial relationships between different road segments, even though the spatial relationships can change dynamically. In addition, many methods also ignore the dynamic time-dependent relationships between traffic flows. To this end, we propose a new network model to model the spatial–temporal correlation of traffic flow dynamics. Specifically, we design a dynamic graph construction method, which can generate dynamic graphs based on data to represent dynamic spatial relationships between road segments. Then, a dynamic graph convolutional network is proposed to extract dynamic spatial features. We further propose a multi-head temporal attention mechanism to learn the dynamic temporal dependencies between different times and then use temporal convolutional networks to extract the dynamic temporal features. The experimental results on real data show that the model proposed in this paper has a better prediction performance than existing models.