learningequality / ka-lite

KA Lite: lightweight web server for serving core Khan Academy content (videos and exercises) without needing internet connectivity
https://learningequality.org/ka-lite/
Other
458 stars 304 forks source link

Move data validation out of forms and into `Model.clean` #1963

Open bcipolli opened 10 years ago

bcipolli commented 10 years ago

Currently, we have lots of data validation put into the forms. However, creating data from other code-paths (within Python code or from the shell) doesn't use that validation code.

All validation that is not form-specific (i.e. doesn't require user interacation) should be pushed into the Model.clean method. In Django, this is the place for custom validation. You specify the field of validation by passing a dictionary when raising a ValidationError error (where the key is the field name that was invalid).

https://docs.djangoproject.com/en/dev/ref/models/instances/#django.db.models.Model.clean

bcipolli commented 10 years ago

I found this a good summary: http://schneck.cc/node/41

aronasorman commented 10 years ago

Not sure if this is important enough for RCT 2, but hell let's put this in here anyway. Could be punted.

bcipolli commented 10 years ago

:+1:

aronasorman commented 10 years ago

0.13.0