Search code examples
djangodjango-modelsdjango-admindjango-widget

Widget filling values in two fields


I know that if I need a custom "selector" for a field in django-admin I need to create a custom widget. But what if the widget have to produce two values, for example X and Y coordinates, how can I fill them in two different fields from the model?


Solution

  • Jannis Leidel released a widget quite a long time ago. django-coordinatesfield As far as I remember, it took the coordinates from a map and passed it a single field and some javascript cut it into 2 coordinates for 2 fields.

    Combined with a custom form it should work quite well