#15271: django.contrib.gis.forms.fields.GeometryField should call to_python before cleaning ------------------------------------------+--------------------------------- Reporter: volrath | Owner: nobody Status: new | Milestone: Component: GIS | Version: SVN Keywords: gis, field, clean, to_python | Triage Stage: Unreviewed Has patch: 1 | ------------------------------------------+--------------------------------- GeometryField overrides the default clean method for Field class and doesn't take in account the call to `to_python` before cleaning of the value. This is important because when using GeometryFields in a form you could want to render it with a MultiWidget, for example:
Let's say we create a PointField (which inherits from GeometryField) with a MultiWidget that renders to FloatFields (one for each coordinate). This widget will return a list with both float values as its value, and that's what will be passed to the clean method. On every other field, we know that this list will be passed to to_python before calling clean, but with GeometryField that's not the case. Following that example, you could redefine the to_python method in our new PointField class to check if the value is instance of a tuple/list (like it's done in a DateTimeField), and transform it to a string representing the Point WKT formed with the two values of that list, but you will also have to redefine clean method to call `to_python` first and then do the cleaning. I'm submitting a simple patch to fix this. -- Ticket URL: <http://code.djangoproject.com/ticket/15271> Django <http://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 django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.