def get_field(self, field):
        field = field.split(':')
        field_type = field[0]

        if field_type.lower() == 'char':
            try:
                length = field[2]
            except IndexError:
                length = 255

            try:
                null = field[3]
                null = 'False'
            except IndexError:
                null = 'True'

            return CHARFIELD_TEMPLATE % {'name': field[1], 'length': length, 'null': null}
        elif field_type.lower() == 'text':
            try:
                null = field[2]
                null = 'False'
            except IndexError:
                null = 'True'

            return {'name': field[1], 'null': null} % TEXTFIELD_TEMPLATE
        elif field_type.lower() == 'int':
            try:
                null = field[2]
                null = 'False'
            except IndexError:
                null = 'True'

            try:
                default = field[3]
            except IndexError:
                default = None

            return INTEGERFIELD_TEMPLATE % {'name': field[1], 'null': null, 'default': default}
        elif field_type.lower() == 'decimal':
            try:
                null = field[4]
                null = 'False'
            except IndexError:
                null = 'True'

            try:
                default = field[5]
            except IndexError:
                default = None

            return DECIMALFIELD_TEMPLATE % {
                'name': field[1],
                'digits': field[2],
                'places': field[3],
                'null': null,
                'default': default,
            }
        elif field_type.lower() == 'datetime':
            try:
                null = field[2]
                null = 'False'
            except IndexError:
                null = 'True'

            try:
                default = field[3]
            except IndexError:
                default = None

            return DATETIMEFIELD_TEMPLATE % {'name': field[1], 'null': null, 'default': default}
        elif field_type.lower() == 'foreign':
            foreign = field[2]
            name = field[1]
            # Check if this foreign key is already in models.py
            if foreign in ('User', 'Group'):
                if not self.is_imported('{0}{1}/models.py'.format(self.SCAFFOLD_APPS_DIR,
                                                                  self.app), foreign):
                    self.imports.append('\nfrom django.contrib.auth.models import User, Group\n')
                return FOREIGNFIELD_TEMPLATE % {'name': name, 'foreign': foreign, 'null': 'True'}
            if self.is_imported('{0}{1}/models.py'.format(
                    self.SCAFFOLD_APPS_DIR, self.app), foreign):
                return FOREIGNFIELD_TEMPLATE % {'name': name, 'foreign': foreign, 'null': 'True'}
            # Check imports
            if self.get_import(foreign):
                self.imports.append(self.get_import(foreign))
                return FOREIGNFIELD_TEMPLATE % {'name': name, 'foreign': foreign, 'null': 'True'}

            self._info('error\t{0}{1}/models.py\t{2} class not found'.format(
                self.SCAFFOLD_APPS_DIR, self.app, foreign), 1)
            return None
dataset/ETHPy150Open Tivix/django-common/django_common/scaffold.py/Scaffold.get_field/swapped operands of `%`