本文整理汇总了Python中django.contrib.gis.db.models.IntegerField方法的典型用法代码示例。如果您正苦于以下问题:Python models.IntegerField方法的具体用法?Python models.IntegerField怎么用?Python models.IntegerField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.contrib.gis.db.models
的用法示例。
在下文中一共展示了models.IntegerField方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: resolve_field
# 需要导入模块: from django.contrib.gis.db import models [as 别名]
# 或者: from django.contrib.gis.db.models import IntegerField [as 别名]
def resolve_field(meta):
type = meta['type']
rest = merge(filter_dict(
# Don't allow default='SEQUENCE'
lambda key, value: not (key=='default' and value=='SEQUENCE'),
# Ignore these keys
remove_keys(meta, ['type', 'auto_populate', 'visible', 'geometry_type', 'nullable'])
), dict(null=True))
if type=='string':
return models.CharField(**rest)
elif type=='integer':
return models.IntegerField(**rest)
elif type=='float':
return models.FloatField(**rest)
elif type=='biginteger':
return models.BigIntegerField(**rest)
elif type=='geometry':
return models.GeometryField(geography=False, **rest)
elif type=='date':
return models.DateField(**rest)
elif type=='datetime':
return models.DateTimeField(**rest)
示例2: dynamic_join_model_class
# 需要导入模块: from django.contrib.gis.db import models [as 别名]
# 或者: from django.contrib.gis.db.models import IntegerField [as 别名]
def dynamic_join_model_class(self, join_models, related_field_names):
"""
Creates an unmanaged subclass of the feature class with extra fields to represent the
the fields of the join_models. This also adds fields for any fields specified in the
related_model_lookup. This is not for join models but ForeignKeys such as BuiltForm
These latter fields must be specified explicitly because the main model and join models
can't populate their foreign keys from the query because the query has to be
a ValuesQuerySet in order to do the join. So we create id versions of the fields here
(e.g. built_form_id) which the query can fill and then use that to manually
set the foreign key reference in the Tastypie resource.
:param join_models: Other feature models whose attributes should be added to the subclass
:param related_field_names: List of field names of foreign key id fields (AutoFields)
"""
main_model_class = self.dynamic_model_class()
manager = main_model_class.objects
# Exclude the following field types. Since the base Feature defines an id we'll still get that, which we want
exclude_field_types = (ForeignKey, ToManyField, OneToOneField, GeometryField)
all_field_paths_to_fields = merge(
# Create fields to represented foreign key id fields
# Our query fetches these ids since it can't fetch related objects (since its a values() query)
map_to_dict(
lambda field_name: [field_name.replace('__', '_x_'),
IntegerField(field_name.replace('__', '_x_'), null=True)],
related_field_names
),
# The join fields for each joined related model
*map(
lambda related_model: related_field_paths_to_fields(
manager,
related_model,
exclude_field_types=exclude_field_types,
fields=limited_api_fields(related_model),
separator='_x_'),
join_models)
)
abstract_feature_class = resolve_module_attr(self.configuration.abstract_class_name)
# Make sure the class name is unique to the related models and the given ConfigEntity
related_models_unique_id = '_'.join(sorted(map(lambda related_model: related_model.__name__, join_models), ))
dynamic_model_clazz = dynamic_model_class(
main_model_class,
self.db_entity.schema,
self.db_entity.table,
class_name="{0}{1}{2}{3}Join".format(
abstract_feature_class.__name__,
self.db_entity.id,
self.config_entity.id,
related_models_unique_id),
fields=all_field_paths_to_fields,
class_attrs=self.configuration.class_attrs or {},
related_class_lookup=self.configuration.related_class_lookup or {},
is_managed=False,
cacheable=False)
logger.info("Created dynamic join model class %s" % dynamic_model_clazz)
logger.debug("Created with model fields %s" % map(lambda field: field.name, dynamic_model_clazz._meta.fields))
logger.debug("Created with related and join fields %s" % all_field_paths_to_fields)
return dynamic_model_clazz