def db_type(self, field):
        """
        Provides a choice to continue using db.Key just for primary key
        storage or to use it for all references (ForeignKeys and other
        relations).

        We also force the "string" db_type (plain string storage) if a
        field is to be indexed, and the "text" db_type (db.Text) if
        it's registered as unindexed.
        """
        if self.connection.settings_dict.get('STORE_RELATIONS_AS_DB_KEYS'):
            if field.primary_key or field.rel is not None:
                return 'key'

        # Primary keys were processed as db.Keys; for related fields
        # the db_type of primary key of the referenced model was used,
        # but RelatedAutoField type was not defined and resulted in
        # "integer" being used for relations to models with AutoFields.
        # TODO: Check with Positive/SmallIntegerField primary keys.
        else:
            if field.primary_key:
                return 'key'
            if field.rel is not None:
                related_field = field.rel.get_related_field()
                if related_field.get_internal_type() == 'AutoField':
                    return 'integer'
                else:
                    return related_field.db_type(connection=self.connection)

        db_type = field.db_type(connection=self.connection)

        # Override db_type of "string" fields according to indexing.
        if db_type in ('string', 'text'):
            indexes = get_model_indexes(field.model)
            if field.attname in indexes['indexed']:
                return 'string'
            elif field.attname in indexes['unindexed']:
                return 'text'

        return db_type
dataset/ETHPy150Open django-nonrel/djangoappengine/djangoappengine/db/creation.py/DatabaseCreation.db_type/original