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. remove the annoying "Hold down control..." messages by arthur 10 months, 3 weeks ago
  2. Serializing booleans correctly when doing dumpdata from a MySQL database using Django 0.96 by chrj 3 years, 6 months ago
  3. FCKEditor replace all vLargeTextField in admin by aronchi 3 years, 3 months ago
  4. TinyIntegerField by Lacour 5 months, 3 weeks ago
  5. model instance to sql insert statement by gsoltis 1 year, 1 month 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?)