Custom field for using MySQL's text type.
text is more compact than the longtext field that Django assigns for models.TextField (2^16 vs. 2^32, respectively)
1 2 3 4 5 | from django.db import models
class NormalTextField(models.Field):
def db_type(self):
return 'text'
|
More like this
- Form field with fixed value by roam 3 days, 20 hours ago
- New Snippet! by Antoliny0919 1 week, 3 days ago
- Add Toggle Switch Widget to Django Forms by OgliariNatan 2 months, 4 weeks ago
- get_object_or_none by azwdevops 6 months, 3 weeks ago
- Mask sensitive data from logger by agusmakmun 8 months, 2 weeks ago
Comments
Hi,
Always use ''.replace() instead of re.sub() when the value to find is not a pattern. Replace method is roughly ten times faster.
In your snippet :
Becomes
with regards :-)
#
Please login first before commenting.