I am getting a Keyerror whenever I specify .values() with SearchQuerySet in django Haystack. For e.g.
required_output = SearchQuerySet()[:10]
works fine. But whenever, I do the following, its throwing KeyError everytime.
required_output = SearchQuerySet().values('title', 'slug')[:10]
Here's the Trackback of the error:
Traceback:
File "/home/project_env/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
114. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/project_env/local/lib/python2.7/site-packages/django/views/generic/base.py" in view
69. return self.dispatch(request, *args, **kwargs)
File "/home/project_env/local/lib/python2.7/site-packages/django/views/generic/base.py" in dispatch
87. return handler(request, *args, **kwargs)
File "/home/project_env/myproject/source/apps/Project/views.py" in get
151. context = self.get_context_data(object=self.object)
File "/home/project_env/myproject/source/apps/Project/views.py" in get_context_data
108. context['related_project'] = SearchQuerySet().values('title')[:10]
File "/home/project_env/local/lib/python2.7/site-packages/haystack/query.py" in __getitem__
266. self._fill_cache(start, bound)
File "/home/project_env/local/lib/python2.7/site-packages/haystack/query.py" in _fill_cache
656. return super(ValuesListSearchQuerySet, self)._fill_cache(start, end, **kwargs)
File "/home/project_env/local/lib/python2.7/site-packages/haystack/query.py" in _fill_cache
166. results = self.query.get_results(**kwargs)
File "/home/project_env/local/lib/python2.7/site-packages/haystack/backends/__init__.py" in get_results
645. self.run(**kwargs)
File "/home/project_env/local/lib/python2.7/site-packages/haystack/backends/elasticsearch_backend.py" in run
918. results = self.backend.search(final_query, **search_kwargs)
File "/home/project_env/local/lib/python2.7/site-packages/haystack/backends/__init__.py" in wrapper
35. return func(obj, query_string, *args, **kwargs)
File "/home/project_env/local/lib/python2.7/site-packages/haystack/backends/elasticsearch_backend.py" in search
504. distance_point=kwargs.get('distance_point'), geo_sort=geo_sort)
File "/home/project_env/local/lib/python2.7/site-packages/haystack/backends/elasticsearch_backend.py" in _process_results
580. source = raw_result['_source']
What version of django-haystack are you using? It looks like there is an open issue for this on the django-haystack GitHub. There is also a patch that should fix it. Looks like you'll have to either wait for the merge, or patch it locally.
Issue #1019
Pull Request #1020
Related
I'm writing an app to represent some systems : some equipments will contain hardware articles, for exemple a server will contain hard drives.
For CRUD operations i'm using DRF ModelViewSet (nothing overriden).
When I delete an equipment which m2m relation is not set it works fine, but I get an error when it is.
Here is a simplified version of the model scheme.
class Hardware(models.Model):
equipment = models.ManyToManyField('Equipment', blank=True, through='HardwareEQ')
# attributes
class HardwareEQ(models.Model):
hardware = models.ForeignKey(Hardware, on_delete=models.CASCADE)
equipment = models.ForeignKey(Equipment, on_delete=models.CASCADE)
# relation attributes
Below is full traceback.
Traceback:
File "C:\Users\USER\Envs\venv\lib\site-packages\django\core\handlers\exception.py" in inner
34. response = get_response(request)
File "C:\Users\USER\Envs\venv\lib\site-packages\django\core\handlers\base.py" in _get_response
115. response = self.process_exception_by_middleware(e, request)
File "C:\Users\USER\Envs\venv\lib\site-packages\django\core\handlers\base.py" in _get_response
113. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\USER\Envs\venv\lib\site-packages\django\views\decorators\csrf.py" in wrapped_view
54. return view_func(*args, **kwargs)
File "C:\Users\USER\Envs\venv\lib\site-packages\rest_framework\viewsets.py" in view
103. return self.dispatch(request, *args, **kwargs)
File "C:\Users\USER\Envs\venv\lib\site-packages\rest_framework\views.py" in dispatch
483. response = self.handle_exception(exc)
File "C:\Users\USER\Envs\venv\lib\site-packages\rest_framework\views.py" in handle_exception
443. self.raise_uncaught_exception(exc)
File "C:\Users\USER\Envs\venv\lib\site-packages\rest_framework\views.py" in dispatch
480. response = handler(request, *args, **kwargs)
File "C:\Users\USER\Envs\venv\lib\site-packages\rest_framework\mixins.py" in destroy
93. self.perform_destroy(instance)
File "C:\Users\USER\Envs\venv\lib\site-packages\rest_framework\mixins.py" in perform_destroy
97. instance.delete()
File "C:\Users\USER\Envs\venv\lib\site-packages\django\db\models\base.py" in delete
918. collector.collect([self], keep_parents=keep_parents)
File "C:\Users\USER\Envs\venv\lib\site-packages\django\db\models\deletion.py" in collect
224. field.remote_field.on_delete(self, field, sub_objs, self.using)
File "C:\Users\USER\Envs\venv\lib\site-packages\django\db\models\deletion.py" in CASCADE
16. source_attr=field.name, nullable=field.null)
File "C:\Users\USER\Envs\venv\lib\site-packages\django\db\models\deletion.py" in collect
220. sub_objs = self.related_objects(related, batch)
File "C:\Users\USER\Envs\venv\lib\site-packages\django\db\models\deletion.py" in related_objects
236. **{"%s__in" % related.field.name: objs}
File "C:\Users\USER\Envs\venv\lib\site-packages\django\db\models\query.py" in filter
892. return self._filter_or_exclude(False, *args, **kwargs)
File "C:\Users\USER\Envs\venv\lib\site-packages\django\db\models\query.py" in _filter_or_exclude
910. clone.query.add_q(Q(*args, **kwargs))
File "C:\Users\USER\Envs\venv\lib\site-packages\django\db\models\sql\query.py" in add_q
1290. clause, _ = self._add_q(q_object, self.used_aliases)
File "C:\Users\USER\Envs\venv\lib\site-packages\django\db\models\sql\query.py" in _add_q
1318. split_subq=split_subq, simple_col=simple_col,
File "C:\Users\USER\Envs\venv\lib\site-packages\django\db\models\sql\query.py" in build_filter
1202. value = self.resolve_lookup_value(value, can_reuse, allow_joins, simple_col)
File "C:\Users\USER\Envs\venv\lib\site-packages\django\db\models\sql\query.py" in resolve_lookup_value
1037. sub_value.resolve_expression(self, reuse=can_reuse, allow_joins=allow_joins)
Exception Type: TypeError at /Sycoma2/ensemble/2/
Exception Value: 'NoneType' object is not callable
Edit : add information
To perform the deletion, I call the hardareEN view using ajax request.
The view is a ModelViewSet, like below :
class HardwareENViewSet(viewsets.ModelViewSet):
queryset = HardwareEN.objects.all()
serializer_class = HardwareENSerializer
The serializer looks like this :
class HardwareENSerializer(VerboseSerializer):
class Meta:
model = HardwareEN
fields = '__all__'
def to_representation(self, instance):
"""
Add hardware data
:param instance:
:return:
"""
data = super().to_representation(instance)
for key, value in HardwareSerializer(instance.hardware).data.items():
try:
if not data[key]:
data[key] = value
except KeyError:
data[key] = value
return data
For information, I tried removing the to_representation override, without more success.
The problem was that I overrode the __getattr__ method of HardwareEN model but forgot to add AttributeError for non-existing attributes. Therefore, when fetching the model attributes, the framework didnt get an attribute error when needed.
I have never had any problems with it previously but when I clicked on it just then, it did not do anything. However my login works fine.
I'm running a custom signup class (so I can include google recaptcha) - this has already been tried and tested to work:
class AllauthSignupForm(forms.Form):
captcha = ReCaptchaField()
class Meta:
model = User
def signup(self, request, user):
""" Required, or else it throws deprecation warnings """
pass
I believe I may have altered the source code in django-allauth/blob/master/allauth/account/forms.py however I can't figure out what I changed. So I tried copy pasting the whole forms.py on github to my forms.py, and that returned this error:
Traceback:
File "/Users/zorgan/Desktop/postr1/lib/python3.5/site-packages/django/core/handlers/exception.py" in inner
41. response = get_response(request)
File "/Users/zorgan/Desktop/postr1/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
187. response = self.process_exception_by_middleware(e, request)
File "/Users/zorgan/Desktop/postr1/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
185. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/zorgan/Desktop/vorsso/venvor/draft1/views.py" in boxes_view
116. return render(request, 'boxes.html', context)
File "/Users/zorgan/Desktop/postr1/lib/python3.5/site-packages/django/shortcuts.py" in render
30. content = loader.render_to_string(template_name, context, request, using=using)
File "/Users/zorgan/Desktop/postr1/lib/python3.5/site-packages/django/template/loader.py" in render_to_string
68. return template.render(context, request)
File "/Users/zorgan/Desktop/postr1/lib/python3.5/site-packages/django/template/backends/django.py" in render
66. return self.template.render(context)
File "/Users/zorgan/Desktop/postr1/lib/python3.5/site-packages/django/template/base.py" in render
205. with context.bind_template(self):
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/contextlib.py" in __enter__
59. return next(self.gen)
File "/Users/zorgan/Desktop/postr1/lib/python3.5/site-packages/django/template/context.py" in bind_template
263. updates.update(processor(self.request))
File "/Users/zorgan/Desktop/project/app/draft1/processors.py" in everywhere
12. allauth_signup = SignupForm(request.POST or None)
File "/Users/zorgan/Desktop/postr1/lib/python3.5/site-packages/allauth/account/forms.py" in __init__
364. super(SignupForm, self).__init__(*args, **kwargs)
File "/Users/zorgan/Desktop/postr1/lib/python3.5/site-packages/allauth/account/forms.py" in __init__
321. getattr(self, 'field_order', None) or default_field_order)
File "/Users/zorgan/Desktop/postr1/lib/python3.5/site-packages/allauth/utils.py" in set_form_field_order
252. for f in fields_order)
File "/Users/zorgan/Desktop/postr1/lib/python3.5/site-packages/allauth/utils.py" in <genexpr>
252. for f in fields_order)
Exception Type: KeyError at /news/
Exception Value: 'email2'
so I believe I may have tampered something with email2.
Any idea what the problem is?
EDIT
Ok when I remove captcha = ReCaptchaField() from my custom form the register works. Any idea why?
EDIT2
So it seems it works on chrome but not firefox. Some problem with google recaptcha not working on firefox.
I'm trying to add a social media authentication to a website using Social-auth-app-django.
So I've created different apps for the most popular social media websites (Facebook, Twitter, Google+), and have set the callback url there.
But I'm coming across an error when I'm redirected back to the website from say Facebook:
Internal Server Error: /oauth/complete/facebook/
Traceback (most recent call last):
File "/usr/local/lib/python3.5/site-packages/django/core/handlers/exception.py", line 39, in inner
response = get_response(request)
File "/usr/local/lib/python3.5/site-packages/django/core/handlers/base.py", line 187, 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 185, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python3.5/site-packages/django/views/decorators/cache.py", line 57, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python3.5/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
return view_func(*args, **kwargs)
File "/usr/local/lib/python3.5/site-packages/social_django/utils.py", line 50, in wrapper
return func(request, backend, *args, **kwargs)
File "/usr/local/lib/python3.5/site-packages/social_django/views.py", line 32, in complete
redirect_name=REDIRECT_FIELD_NAME, *args, **kwargs)
File "/usr/local/lib/python3.5/site-packages/social_core/actions.py", line 41, in do_complete
user = backend.complete(user=user, *args, **kwargs)
File "/usr/local/lib/python3.5/site-packages/social_core/backends/base.py", line 40, in complete
return self.auth_complete(*args, **kwargs)
File "/usr/local/lib/python3.5/site-packages/social_core/utils.py", line 252, in wrapper
return func(*args, **kwargs)
File "/usr/local/lib/python3.5/site-packages/social_core/backends/facebook.py", line 110, in auth_complete
return self.do_auth(access_token, response, *args, **kwargs)
File "/usr/local/lib/python3.5/site-packages/social_core/backends/facebook.py", line 152, in do_auth
return self.strategy.authenticate(*args, **kwargs)
File "/usr/local/lib/python3.5/site-packages/social_django/strategy.py", line 115, in authenticate
return authenticate(*args, **kwargs)
File "/usr/local/lib/python3.5/site-packages/django/contrib/auth/__init__.py", line 74, in authenticate
user = backend.authenticate(**credentials)
File "/usr/local/lib/python3.5/site-packages/social_core/backends/base.py", line 80, in authenticate
return self.pipeline(pipeline, *args, **kwargs)
File "/usr/local/lib/python3.5/site-packages/social_core/backends/base.py", line 83, in pipeline
out = self.run_pipeline(pipeline, pipeline_index, *args, **kwargs)
File "/usr/local/lib/python3.5/site-packages/social_core/backends/base.py", line 105, in run_pipeline
for idx, name in enumerate(pipeline[pipeline_index:]):
TypeError: unhashable type: 'slice'
Below is a summary of how I've configured social_django:
In settings.py:
INSTALLED_APPS = [
'social_django',
...
]
AUTHENTICATION_BACKENDS = (
'social_core.backends.google.GoogleOAuth2',
'social_core.backends.twitter.TwitterOAuth',
'social_core.backends.facebook.FacebookOAuth2',
'django.contrib.auth.backends.ModelBackend',
)
SOCIAL_AUTH_FACEBOOK_KEY = 'xxx'
SOCIAL_AUTH_FACEBOOK_SECRET = 'xxx'
...
PIPELINE = {
'PIPELINE_ENABLED': True,
'STYLESHEETS': {...},
'JAVASCRIPT': {...},
'JS_COMPRESSOR': 'pipeline.compressors.NoopCompressor',
'COMPILERS': (
'pipeline.compilers.sass.SASSCompiler',
)
}
Afterwards, I've obviously migrated the database to create the new tables.
Please find below the versions of Django and social_django:
Django: 1.10.5
social_django: 1.2.0
Regarding the pipeline used, I'm using django-pipeline but it's just for compiling SASS files to CSS.
What might cause this error?
Adding the pipeline below to settings.py seems to have fixed the problem (source):
SOCIAL_AUTH_PIPELINE = (
'social_core.pipeline.social_auth.social_details',
'social_core.pipeline.social_auth.social_uid',
'social_core.pipeline.social_auth.social_user',
'social_core.pipeline.user.get_username',
'social_core.pipeline.user.create_user',
'social_core.pipeline.social_auth.associate_user',
'social_core.pipeline.social_auth.load_extra_data',
'social_core.pipeline.user.user_details',
'social_core.pipeline.social_auth.associate_by_email',
)
This error raises when trying to get a slice from a dict object. So, yes at the point of the last line of the traceback, pipelines is a dict object when it is supposed to be a sequence which default value is sociel_core.pipeline.DEFAULT_AUTH_PIPELINE unless your settings provides a PIPELINE object.
https://github.com/python-social-auth/social-core/blob/ccc50a5932b199a1a5209a08563c8997eb99391d/social_core/strategy.py#L99
https://github.com/python-social-auth/social-core/blob/ccc50a5932b199a1a5209a08563c8997eb99391d/social_core/pipeline/init.py#L1
Thus I suspect something probably in your settings module that messes this PIPELINE that should be a sequence (list, tuple, custom) and not a dict.
Hints: install ipython and play with python manage.py shell and inspect the followings.
>>> from social_core.strategy import BaseStrategy
>>> st = BaseStrategy()
>>> st.get_pipeline()
---> ???
>>> from django.conf import settings
>>> settings.PIPELINE
---> ???
Hope this helped
While upgrading my project from django 1.5.1 to 1.6.5, I am facing this weird issue.
This is forbidden when an 'atomic' block is active.
I am aware of the Database Transaction changes for django 1.6 and made the setting changes accordingly. Works for most part, except when request.user object is accessed.
The code, for instance:
with transaction.atomic():
if hasattr(request, 'user') and getattr(request.user, 'id', None):
#blah
Here is the stacktrace:
Environment:
Request Method: GET
Request URL: <domain>/api/v1/browser_id/
Django Version: 1.6.5
Python Version: 2.7.3
<Installed Applications & Middlewares snipped for brevity>
Traceback:
File "/usr/local/virtualenvs/karthik-django165/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
112. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/virtualenvs/karthik-django165/local/lib/python2.7/site-packages/django/db/transaction.py" in inner
371. return func(*args, **kwargs)
File "/home/kravindra/workspace/puppysite/puppy/kennel/views/etag_session.py" in browser_id
43. if hasattr(request, 'user') and getattr(request.user, 'id', None):
File "/usr/local/virtualenvs/karthik-django165/local/lib/python2.7/site-packages/django/utils/functional.py" in inner
213. self._setup()
File "/usr/local/virtualenvs/karthik-django165/local/lib/python2.7/site-packages/django/utils/functional.py" in _setup
298. self._wrapped = self._setupfunc()
File "/usr/local/virtualenvs/karthik-django165/local/lib/python2.7/site-packages/django/contrib/auth/middleware.py" in <lambda>
18. request.user = SimpleLazyObject(lambda: get_user(request))
File "/usr/local/virtualenvs/karthik-django165/local/lib/python2.7/site-packages/django/contrib/auth/middleware.py" in get_user
10. request._cached_user = auth.get_user(request)
File "/usr/local/virtualenvs/karthik-django165/local/lib/python2.7/site-packages/django/contrib/auth/__init__.py" in get_user
140. user_id = request.session[SESSION_KEY]
File "/usr/local/virtualenvs/karthik-django165/local/lib/python2.7/site-packages/django/contrib/sessions/backends/base.py" in __getitem__
47. return self._session[key]
File "/usr/local/virtualenvs/karthik-django165/local/lib/python2.7/site-packages/django/contrib/sessions/backends/base.py" in _get_session
173. self._session_cache = self.load()
File "/usr/local/virtualenvs/karthik-django165/local/lib/python2.7/site-packages/django/contrib/sessions/backends/cached_db.py" in load
52. self.create()
File "/usr/local/virtualenvs/karthik-django165/local/lib/python2.7/site-packages/django/contrib/sessions/backends/db.py" in create
40. self.save(must_create=True)
File "/usr/local/virtualenvs/karthik-django165/local/lib/python2.7/site-packages/django/contrib/sessions/backends/cached_db.py" in save
62. super(SessionStore, self).save(must_create)
File "/usr/local/virtualenvs/karthik-django165/local/lib/python2.7/site-packages/django/contrib/sessions/backends/db.py" in save
63. obj.save(force_insert=must_create, using=using)
File "/usr/local/virtualenvs/karthik-django165/local/lib/python2.7/site-packages/django/db/models/base.py" in save
545. force_update=force_update, update_fields=update_fields)
File "/usr/local/virtualenvs/karthik-django165/local/lib/python2.7/site-packages/django/db/models/base.py" in save_base
582. update_fields=update_fields, raw=raw, using=using)
File "/usr/local/virtualenvs/karthik-django165/local/lib/python2.7/site-packages/django/dispatch/dispatcher.py" in send
185. response = receiver(signal=self, sender=sender, **named)
File "/usr/local/virtualenvs/karthik-django165/local/lib/python2.7/site-packages/django/db/transaction.py" in inner
430. with self:
File "/usr/local/virtualenvs/karthik-django165/local/lib/python2.7/site-packages/django/db/transaction.py" in __enter__
422. self.entering(self.using)
File "/usr/local/virtualenvs/karthik-django165/local/lib/python2.7/site-packages/django/db/transaction.py" in entering
483. enter_transaction_management(using=using)
File "/usr/local/virtualenvs/karthik-django165/local/lib/python2.7/site-packages/django/db/transaction.py" in enter_transaction_management
70. get_connection(using).enter_transaction_management(managed, forced)
File "/usr/local/virtualenvs/karthik-django165/local/lib/python2.7/site-packages/django/db/backends/__init__.py" in enter_transaction_management
287. self.validate_no_atomic_block()
File "/usr/local/virtualenvs/karthik-django165/local/lib/python2.7/site-packages/django/db/backends/__init__.py" in validate_no_atomic_block
367. "This is forbidden when an 'atomic' block is active.")
Exception Type: TransactionManagementError at /api/v1/browser_id/
Exception Value: This is forbidden when an 'atomic' block is active.
Looking at the stacktrace,
/usr/local/virtualenvs/karthik-django165/local/lib/python2.7/site-packages/django/contrib/sessions/backends/cached_db.py in load
self.create() ...
▼ Local vars
Variable Value
e
DoesNotExist('Session matching query does not exist.',)
self
<django.contrib.sessions.backends.cached_db.SessionStore object at 0x7f61d401c6d0>
data
None
SessionStore raises an exception.
Using POSTGRES as the backend database.
The backend session store related settings are:
SESSION_ENGINE = 'django.contrib.sessions.backends.cached_db' #which is persistent storage
ATOMIC_REQUESTS = True
Any pointers on how to fix this issue?
I found that there are a bunch of Questions on SO, and blogposts that address TransactionManagementError issue in general, but nothing to address this issue in particular
From the traceback it looks like one of your post_save signal receiver is still using one of the following deprecated transaction APIs:
transaction.Transaction
transaction.autocommit
transaction.commit_on_success
transaction.commit_manually
commit_on_success_unless_managed
Make sure to replace it with a transaction.atomic instance instead and your issue should go away.
Let me know if you have trouble finding the culprit receiver.
On production server I receive the attached error, not emerging on the development server. Both environments are identical (same Django 1.6 and Python 2.7 versions, using virtualenvs same RDBMS version - a postgresql 9.1 server, running locally with a reasonably similar configuration than on production).
The offending code, I suppose, is in views.py:
from djgeojson.views import GeoJSONLayerView
class FilteredMapLayer(GeoJSONLayerView):
def get_queryset(self):
qs = super(FilteredMapLayer, self).get_queryset()
bbox_data = self.request.GET.get('bbox', None)
if bbox_data is not None:
bbox_data = ( x for x in map(float, bbox_data.split(',')))
bbox = Polygon.from_bbox(bbox_data)
features = qs.filter(geom__bboverlaps=bbox)
else:
features = qs
return features
since this is the urlpattern definition that, when requested, triggers the error
url(r'^data.geojson$', FilteredMapLayer.as_view(model=MyModelName, precision = 2, simplify = 0.5), name='myurl'),
here is the complete traceback, that does not provide me any info on where I did wrong....
Traceback (most recent call last):
File "/home/m2user/webapps/enea/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 114, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/m2user/webapps/enea/local/lib/python2.7/site-packages/django/utils/decorators.py", line 99, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/home/m2user/webapps/enea/local/lib/python2.7/site-packages/django/views/generic/base.py", line 69, in view
return self.dispatch(request, *args, **kwargs)
File "/home/m2user/webapps/enea/local/lib/python2.7/site-packages/django/utils/decorators.py", line 29, in _wrapper
return bound_func(*args, **kwargs)
File "/home/m2user/webapps/enea/local/lib/python2.7/site-packages/django/utils/decorators.py", line 99, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/home/m2user/webapps/enea/local/lib/python2.7/site-packages/django/utils/decorators.py", line 25, in bound_func
return func(self, *args2, **kwargs2)
File "/home/m2user/webapps/enea/local/lib/python2.7/site-packages/djgeojson/views.py", line 51, in dispatch
return super(GeoJSONLayerView, self).dispatch(*args, **kwargs)
File "/home/m2user/webapps/enea/local/lib/python2.7/site-packages/django/views/generic/base.py", line 87, in dispatch
return handler(request, *args, **kwargs)
File "/home/m2user/webapps/enea/local/lib/python2.7/site-packages/django/views/generic/list.py", line 153, in get
return self.render_to_response(context)
File "/home/m2user/webapps/enea/local/lib/python2.7/site-packages/djgeojson/views.py", line 41, in render_to_response
**options)
File "/home/m2user/webapps/enea/local/lib/python2.7/site-packages/djgeojson/serializers.py", line 335, in serialize
self.serialize_queryset(queryset)
File "/home/m2user/webapps/enea/local/lib/python2.7/site-packages/djgeojson/serializers.py", line 277, in serialize_queryset
self.handle_field(obj, self.geometry_field)
File "/home/m2user/webapps/enea/local/lib/python2.7/site-packages/djgeojson/serializers.py", line 177, in handle_field
geometry = self._handle_geom(GEOSGeometry(value))
File "/home/m2user/webapps/enea/local/lib/python2.7/site-packages/djgeojson/serializers.py", line 159, in _handle_geom
geometry.transform(self.srid)
File "/home/m2user/webapps/enea/local/lib/python2.7/site-packages/django/contrib/gis/geos/geometry.py", line 510, in transform
raise GEOSException("Calling transform() with no SRID set is not supported")
.... since if I check the features stored in the model, they all have a SRID defined (4326) and I'm not trying to call any transformation - I suppose - since I'm rendering the view using the same SRID. And, I repeat myself here, the same request on dev server works seamlessly.
What I've tried so far:
recreated the DB from scratch, reloaded all the data. Using Django admin I can see/edit the features stored
checked all software dependences and updated the code from trunk of https://github.com/makinacorpus/django-geojson
checked model definitions: all have geom = models.MultiPolygonField(srid=4326) fields
searched Google and SO for similar issues without any luck
I have no more ideas. Any suggestion is welcome!
I was able to solve my issue by uninstalling and then re-installing all the libraries (as ubuntu packages), the python interpreter, all the code, by re-generating the database (including reinstalling postgis) and then by completely restart nginx (and thus gunicorn). No libraries were updated, however, so I still do not understand what really happened.