openwisp / django-rest-framework-gis

Geographic add-ons for Django REST Framework. Maintained by the OpenWISP Project.
http://openwisp.org
MIT License
1.07k stars 200 forks source link

[bug] id_field is not deserialized #272

Closed restaste closed 2 years ago

restaste commented 2 years ago

Hi! Thanks for the great lib :)

We noticed that although a model's id can be serialized from a django model to a predefined property (through id_field, as documented here), the opposite is not true: a geojson feature id will not be attributed back to the model's id field.

We figured this was an oversight and have patched it in our fork. We'd love to contribute this upstream, should we go ahead and open a PR for it?

nemesifier commented 2 years ago

Hi @restaste, thanks for reporting, what do you mean exactly, like if using a PUT to create and the ID is specified, the ID is ignored and the object is created with a different ID, or how would the use case or failing test look like?

restaste commented 2 years ago

Hi @nemesisdesign, yes it's exactly this (a given ID is ignored). You can take a look at the PR in our fork if you want to get an idea of what a failing test could look like.