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

GeopositionField returns string instead of Geoposition() after loaddata with python 3.4 #24

Closed
lucacorti opened this issue Jun 9, 2014 · 5 comments

Comments

@lucacorti
Copy link
Contributor

Hi,

I dumped my models with python 2.7 and loaded them on a different django install with python 3.4. after loaddata geoposition returns a string instead of a Geoposition object:

on python 2.7:

>>> model.position
Geoposition(45.4855921,9.2202867)
>>> model.position.latitude
Decimal('45.4855921')
>>> model.position.longitude
Decimal('9.2202867')

on python 3.4:

>>> model.position
'45.4906771,9.16936499999997'
>>> model.position.latitude
Traceback (most recent call last):
  File "<console>", line 1, in <module>
AttributeError: 'str' object has no attribute 'latitude'
>>> model.position.longitude
Traceback (most recent call last):
  File "<console>", line 1, in <module>
AttributeError: 'str' object has no attribute 'longitude'

This obviously breaks code elsewhere in my app relying on Geoposition to be returned.

@lucacorti lucacorti changed the title GeopositionField returns string instead of Geoposition() after loaddata with on python 3.4 GeopositionField returns string instead of Geoposition() after loaddata with python 3.4 Jun 9, 2014
@raratiru
Copy link
Contributor

I have the same issue in Python 3.3 and I would like to report it.

Meanwhile, I consider using

Try:
    ...
Except AttributeError:
    ...

-with robust unit testing- to bypass this problem.

_Update_
In the admin interface, the model works as expected. The issue exists only through python interpreter.

@saintdragon2
Copy link

I have same problem.

philippbosch added a commit that referenced this issue Jul 29, 2014
philippbosch added a commit that referenced this issue Jul 29, 2014
@philippbosch
Copy link
Owner

This should now be fixed in 31ba534. I bumped the version to 0.2.2 and uploaded to PyPI.

@saintdragon2 @raratiru @lucacorti could you please try this out and let me know if your problem is fixed? Thanks!

@raratiru
Copy link
Contributor

Yes, it works great, thank you!

In [1]: from testing.models import Simio

In [2]: one = Simio(name='55', point_position='2.345324234,5.2344234')

In [3]: one.save()

In [4]: one.point_position
Out[4]: Geoposition(2.345324234,5.2344234)

In [5]: one.point_position.longitude
Out[5]: Decimal('5.2344234')

In [6]: one.point_position.latitude
Out[6]: Decimal('2.345324234')

@philippbosch
Copy link
Owner

Thanks @raratiru!
Closing.

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

4 participants