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'

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?)

You may use Markdown syntax here, but raw HTML will be removed.