MySQL "Text" Type Model Field

1
2
3
4
5
from django.db import models

class NormalTextField(models.Field):		
	def db_type(self):
		return 'text'

More like this

  1. FCKEditor replace all vLargeTextField in admin by aronchi 4 years, 6 months ago
  2. ByteSplitterField by Lacour 1 year, 8 months ago
  3. Custom ImageField filename by allieus 2 years, 11 months ago
  4. Serializing booleans correctly when doing dumpdata from a MySQL database using Django 0.96 by chrj 4 years, 9 months ago
  5. Modifying the fields of a third/existing model class by marinho 2 years, 4 months ago

Comments

Romain Hardouin (on August 6, 2008):

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 :

value = sub("\n", "", value)

Becomes

value.replace('\n', '')

with regards :-)

#

(Forgotten your password?)