Haki Benita
1 min readJan 3, 2019

--

The problems I see with implementing validation on the clean method are:

  1. They will only be called automatically by forms (django.forms and admin) — this is not always the case.
  2. To force validation on every save, you either have to be very discipline or override save. Overriding save can work but It means interfering with Django inner works (you have to ask your self, why didn’t Django just add clean to save ?). Also, external apps that rely on Django save might not work as expected (ValidationError is not an expected outcome of obj.save()).

--

--

Haki Benita
Haki Benita

Written by Haki Benita

Full Stack Developer, Team Leader, Independent. More from me at https://hakibenita.com

Responses (2)