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

'json.encoder' has no attribute 'FLOAT_REPR' #80

Closed
XavierCLL opened this issue Aug 14, 2016 · 4 comments
Closed

'json.encoder' has no attribute 'FLOAT_REPR' #80

XavierCLL opened this issue Aug 14, 2016 · 4 comments

Comments

@XavierCLL
Copy link

Using python 3.5

Internal Server Error: /data.geojson/2016-8-13/2016-8-14/
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/site-packages/django/core/handlers/base.py", line 149, in get_response
    response = self.process_exception_by_middleware(e, request)
  File "/usr/local/lib/python3.5/site-packages/django/core/handlers/base.py", line 147, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python3.5/site-packages/django/views/generic/base.py", line 68, in view
    return self.dispatch(request, *args, **kwargs)
  File "/usr/local/lib/python3.5/site-packages/django/utils/decorators.py", line 67, in _wrapper
    return bound_func(*args, **kwargs)
  File "/usr/local/lib/python3.5/site-packages/django/utils/decorators.py", line 149, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/usr/local/lib/python3.5/site-packages/django/utils/decorators.py", line 63, in bound_func
    return func.__get__(self, type(self))(*args2, **kwargs2)
  File "/usr/local/lib/python3.5/site-packages/djgeojson/views.py", line 79, in dispatch
    return super(GeoJSONLayerView, self).dispatch(*args, **kwargs)
  File "/usr/local/lib/python3.5/site-packages/django/views/generic/base.py", line 88, in dispatch
    return handler(request, *args, **kwargs)
  File "/usr/local/lib/python3.5/site-packages/django/views/generic/list.py", line 175, in get
    return self.render_to_response(context)
  File "/usr/local/lib/python3.5/site-packages/djgeojson/views.py", line 69, in render_to_response
    **options)
  File "/usr/local/lib/python3.5/site-packages/djgeojson/serializers.py", line 381, in serialize
    self.end_serialization()
  File "/usr/local/lib/python3.5/site-packages/djgeojson/serializers.py", line 162, in end_serialization
    floatrepr = json.encoder.FLOAT_REPR
AttributeError: module 'json.encoder' has no attribute 'FLOAT_REPR'

I tested replace the line 162 from serializers.py with that from:
floatrepr = lambda o: format(o, '.2f')

and for me fix this error and work good, but need more test.

tochev added a commit to tochev/django-geojson that referenced this issue Aug 21, 2016
tochev added a commit to tochev/django-geojson that referenced this issue Aug 21, 2016
@askpatrickw
Copy link

+1 I've hit this as well...

@cleder
Copy link

cleder commented Sep 8, 2016

👍 +1

@ad-m
Copy link

ad-m commented Dec 11, 2016

👍 +1

@kresdjan
Copy link

kresdjan commented Feb 21, 2017

👍 +1

Gagaro pushed a commit that referenced this issue Feb 28, 2017
@Gagaro Gagaro closed this as completed in fd27091 Feb 28, 2017
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

5 participants