Changeset 7024
- Timestamp:
- 01/18/08 09:52:37 (8 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/gis/django/contrib/gis/utils/layermapping.py
r7013 r7024 125 125 class InvalidString(LayerMapError): pass 126 126 class InvalidDecimal(LayerMapError): pass 127 class InvalidInteger(LayerMapError): pass 127 128 class MissingForeignKey(LayerMapError): pass 128 129 … … 407 408 raise InvalidString('%s model field maximum string length is %s, given %s characters.' % 408 409 (model_field.name, model_field.max_length, len(val))) 409 elif isinstance(ogr_field, OFTReal) :410 elif isinstance(ogr_field, OFTReal) and isinstance(model_field, models.DecimalField): 410 411 try: 411 412 # Creating an instance of the Decimal value to use. 412 413 d = Decimal(str(ogr_field.value)) 413 414 except: 414 raise InvalidDecimal('Could not construct decimal from: %s' % ogr_field )415 raise InvalidDecimal('Could not construct decimal from: %s' % ogr_field.value) 415 416 416 417 # Getting the decimal value as a tuple. … … 435 436 (model_field.max_digits, model_field.decimal_places, max_prec)) 436 437 val = d 438 elif isinstance(ogr_field, OFTReal) and isinstance(model_field, models.IntegerField): 439 # If there's an OFTReal field with precision greater than 0 is mapped to 440 # an IntegerField, the decimal places will be truncated. 441 try: 442 val = int(ogr_field.value) 443 except: 444 raise InvalidInteger('Could not construct integer from: %s' % ogr_field.value) 437 445 else: 438 446 val = ogr_field.value
