Python django.contrib.gis.db.models.IntegerField() Examples
The following are 2
code examples of django.contrib.gis.db.models.IntegerField().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
django.contrib.gis.db.models
, or try the search function
.
Example #1
Source File: feature_class_creator.py From urbanfootprint with GNU General Public License v3.0 | 6 votes |
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)
Example #2
Source File: feature_class_creator.py From urbanfootprint with GNU General Public License v3.0 | 4 votes |
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