#18367: LayerMapping.verify_ogr_field fails when trying to map OFTString to
TextField
-----------------------------+--------------------
Reporter: geoffhing@… | Owner: nobody
Type: Bug | Status: new
Component: GIS | Version: 1.4
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+--------------------
In {{{LayerMapping.verify_ogr_field()}}}, there is this check around line
335 of contrib/gis/utils/layermapping.py:
{{{
val = ogr_field.value
if len(val) > model_field.max_length:
raise InvalidString('%s model field maximum string
length is %s, given %s characters.' %
(model_field.name,
model_field.max_length, len(val)))
}}}
When model_field is an instance of {{{models.TextField}}} this check will
fail because {{{model_field.max_length}}} is None.
I was able to fix this by checking model_field.max_length before the
length test:
{{{
val = ogr_field.value
if model_field.max_length and len(val) >
model_field.max_length:
raise InvalidString('%s model field maximum string
length is %s, given %s characters.' %
(model_field.name,
model_field.max_length, len(val)))
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/18367>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.