These are chat archives for django/django

Feb 2019
Christopher Sabater Cordero
Feb 14 02:50
Can anyone explain what the difference between a forms.Field and an models.Field?
I made a custom field that subclasses models.CharField, overrode the to_python function and its related methods and then added the name of the field to a Form's Meta.fields attribute
And for whatever reason the to_python and get_db_value methods aren't being called
Feb 14 08:21
forms.Field is for converting to data from the request to python types (the to_python method)
models.Field is for converting back and forth between python and the database
you'd need to add your models.Field override to the actual model class field you want overridden
Christopher Sabater Cordero
Feb 14 13:44
so forms.Field is supposed to have the to_python method? or is models.Field also supposed to have it?
wait yeah, definitely the models.Field version has a to_python method
Miracle Ayodele
Feb 14 13:56
Thanks @bittner