You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now, say a customized React form exists for this field and some backend programmer wants to check if it's empty by checking if it's not equal to the empty string. Depending how the form was programmed, certain boolean checks may pass and others fail in an unpredictable way, because when the field is unfilled it may more may not be stringlike.
I've had unexpected exceptions when writing code to get data from Dispatch because of this.
Django convention is to never allow null=True on a TextField or CharField unless circumstances demand it. Rather, blank=True, but with default='', is preferred. This guarantees when the SQL table is supposed to store data that should be interpreted as a string by Python, we don't end up needing to do checks that guarantee our object is sufficiently string-like to do the operations we need; its type is string, not "string or null".
The text was updated successfully, but these errors were encountered:
Here is an example in class Subsection:
description = TextField(null=True, blank=True)
Now, say a customized React form exists for this field and some backend programmer wants to check if it's empty by checking if it's not equal to the empty string. Depending how the form was programmed, certain boolean checks may pass and others fail in an unpredictable way, because when the field is unfilled it may more may not be stringlike.
I've had unexpected exceptions when writing code to get data from Dispatch because of this.
Django convention is to never allow
null=True
on a TextField or CharField unless circumstances demand it. Rather,blank=True
, but withdefault=''
, is preferred. This guarantees when the SQL table is supposed to store data that should be interpreted as a string by Python, we don't end up needing to do checks that guarantee our object is sufficiently string-like to do the operations we need; its type is string, not "string or null".The text was updated successfully, but these errors were encountered: