Hi. Django-axes is an already existing application which is widely considered as the standard for this.
Axes is basically used to detect failed login attempts and notify the user of the same.
Also, there is Django-ratelimit if you are considering taking a more general approach.
Hope this helped!