Skip to content
New issue

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

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

Already on GitHub? # to your account

Object has no attribute 'geom' #99

Open
chseluv opened this issue Oct 7, 2018 · 1 comment
Open

Object has no attribute 'geom' #99

chseluv opened this issue Oct 7, 2018 · 1 comment

Comments

@chseluv
Copy link

chseluv commented Oct 7, 2018

when the views is called I get

AttributeError: 'Apartment' object has no attribute 'geom'

does the model field necessarily storing GeoJSON have to be called "geom"? In my case it's conveniently called "position"

class Apartment(models.Model):
[some indentation] position = PointField()

but I can't serialize these model-objects by doing so in my view:

GeoJSONSerializer().serialize(Apartment.objects.all(), use_natural_keys=True, with_modelname=False)

is there something I ignore or that I'm not understanding?

PS. I'm also looking for information about dealing with the GeoJSON "properties" data, I need to populate it with information from my models. Any documentation about this? I couldn't locate it.

@Gagaro
Copy link
Member

Gagaro commented Nov 13, 2018

There is an attribute on the view to change the name of the model field used:

geometry_field = 'geom'

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

No branches or pull requests

2 participants