Finally, I find out that I can create my own datatype! (I use Django 1.2 beta 1.)
in models.py: from django.db import models from django.db.models import * from django.utils.translation import ugettext_lazy as _ class myCharField(Field): def __init__(self, *args, **kwargs): self.max_length = kwargs['max_length'] super(myCharField, self).__init__(*args, **kwargs) def db_type(self, connection): if connection.settings_dict['ENGINE'] == 'django.db.backends.mysql': return 'char(%s)' % self.max_length else: #raise exception pass class myCharClass(models.Model): myCF = myCharField(max_length=30) [SQL] CREATE TABLE test_mycharclass ( mycf char(30) ) ; regards, Stanley Huang 2010/4/21 derek <gamesb...@gmail.com> > On Apr 20, 1:31 pm, Huang Stanley <wenlien1...@gmail.com> wrote: > > Hi all: > > > > I try to find all fields but only IPAddressField is char data type, > > but it's a fix-length char data type for 15 characters. > > > > Is there any field that I can use for this purpose. > > > > PS. I use django 1.2 beta 1 on Ubuntu. > > > > Thanks for your kindly assistance. > > > > regards, > > > > Stanley Huang > > How about: > http://docs.djangoproject.com/en/1.1/ref/models/fields/#charfield > or > http://docs.djangoproject.com/en/1.1/ref/forms/fields/#charfield > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.