I know that with a regular string you can do x.len() to get the length of it, but a Django model TextField doesn’t seem to want that. I have found and looked at the model field reference. How do I get the length of a text field in Django? Help and examples appreciated.
Share
Try
len(obj.your_field). This should give you what you want because the result it going to be a an object of the corresponding data type (both TextField fields and CharField fields will be strings). Here is a quick example based on the docs:Also, there is no ‘string’.len() method in python unless you have added it somehow.