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
- Browser-native date input field by kytta 1 month ago
- Generate and render HTML Table by LLyaudet 1 month, 1 week ago
- My firs Snippets by GutemaG 1 month, 1 week ago
- FileField having auto upload_to path by junaidmgithub 2 months, 2 weeks ago
- LazyPrimaryKeyRelatedField by LLyaudet 2 months, 3 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.