django-geojson icon indicating copy to clipboard operation
django-geojson copied to clipboard

'Serializer' object has no attribute 'deserialize'

Open easherma opened this issue 7 years ago • 6 comments

Thanks for this project. I'm playing around with importing it in the django shell to see how deserialization works on my data.

However, I get 'Serializer' object has no attribute 'deserialize' if I try to import

>>> from djgeojson.serializers import Serializer as GeoJSONSerializer
>>> GeoJSONSerializer().deserialize()

Does this method not exist if I'm running from shell? The documentation is unclear to me.

easherma avatar Mar 22 '17 18:03 easherma

The documentation looks wrong. And i'm not sure the Deserializer is really tested because it looks like there is an exception which is not imported..

From looking through the tests, I'd say that you would need to do something like:

>>> from django.core import serializers
>>> serializers.deserialize('geojson', your_geojson)

Can you tell me if this works? Thanks.

Gagaro avatar Mar 23 '17 08:03 Gagaro

I ran into the same error as @easherma when trying to de-serialize some GeoJSON that was returned from a geocoder API.

I tried @Gagaro's suggestion but it resulted in a different error:

{SerializerDoesNotExist}'geojson is a serialization-only serializer'

That's a pity. So far as I can tell there's no other library that will attempt to nicely convert some valid GeoJSON into a spatially aware Django model. Luckily I'm working with points so it's pretty easy to just parse them out from the JSON. But such a thing could be useful for more complex feature collections.

hughstimson avatar May 09 '18 05:05 hughstimson

The thing is we do have a deserializer in the tests: https://github.com/makinacorpus/django-geojson/blob/master/djgeojson/tests.py#L69-L131

We also have a Deserializer method, maybe you could try that one: https://github.com/makinacorpus/django-geojson/blob/master/djgeojson/serializers.py#L479-L521

I'm not sure what's up with all this.

Gagaro avatar May 15 '18 08:05 Gagaro

I haven't been able to use the Deserializer class. Will keep trying though.

This part of the documentation is wrong, https://django-geojson.readthedocs.io/en/latest/advanced.html#low-level-deserializer

probably outdated right?

marco-silva0000 avatar Oct 12 '18 11:10 marco-silva0000

Would be nice to at least fix the docs. This was my first experience of using the whole makinacorpus Geodjango stack and it didn't inspire immediate confidence!

andybak avatar Apr 03 '20 13:04 andybak

It seems to be that was never implemented

erwinfeser avatar Jul 13 '20 15:07 erwinfeser