Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'Serializer' object has no attribute 'deserialize' #87

Open
easherma opened this issue Mar 22, 2017 · 6 comments
Open

'Serializer' object has no attribute 'deserialize' #87

easherma opened this issue Mar 22, 2017 · 6 comments

Comments

@easherma
Copy link

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.

@Gagaro
Copy link
Member

Gagaro commented Mar 23, 2017

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.

@hughstimson
Copy link

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.

@Gagaro
Copy link
Member

Gagaro commented May 15, 2018

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.

@marco-silva0000
Copy link

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?

@andybak
Copy link

andybak commented Apr 3, 2020

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!

@erwinfeser
Copy link

It seems to be that was never implemented

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants