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 1 year, 2 months ago
  2. Serializing booleans correctly when doing dumpdata from a MySQL database using Django 0.96 by chrj 3 years, 9 months ago
  3. FCKEditor replace all vLargeTextField in admin by aronchi 3 years, 7 months ago
  4. TinyIntegerField by Lacour 9 months, 1 week ago
  5. model instance to sql insert statement by gsoltis 1 year, 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?)