Django Haystack random errors using Whoosh - django

I am using django-haystack and Whoosh on my Ubuntu server and finding that certain search queries just raise an error page, and I have no idea why this is happening...
I am using the following ones
Whoosh==2.4.0
django-haystack==1.2.7
And I also run python manage.py update_index once every hour
Example traceback
Traceback (most recent call last):
File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 111, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/newrelic-1.2.0.246/newrelic/hooks/framework_django.py", line 430, in __call__
return self.__wrapped(*args, **kwargs)
File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/haystack/views.py", line 50, in __call__
return self.create_response()
File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/haystack/views.py", line 145, in create_response
return render_to_response(self.template, context, context_instance=self.context_class(self.request))
File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/shortcuts/__init__.py", line 20, in render_to_response
return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/loader.py", line 188, in render_to_string
return t.render(context_instance)
File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/base.py", line 123, in render
return self._render(context)
File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/newrelic-1.2.0.246/newrelic/api/function_trace.py", line 82, in __call__
return self._nr_next_object(*args, **kwargs)
File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/base.py", line 117, in _render
return self.nodelist.render(context)
File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/base.py", line 744, in render
bits.append(self.render_node(node, context))
File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/base.py", line 757, in render_node
return node.render(context)
File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/loader_tags.py", line 127, in render
return compiled_parent._render(context)
File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/newrelic-1.2.0.246/newrelic/api/function_trace.py", line 82, in __call__
return self._nr_next_object(*args, **kwargs)
File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/base.py", line 117, in _render
return self.nodelist.render(context)
File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/base.py", line 744, in render
bits.append(self.render_node(node, context))
File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/base.py", line 757, in render_node
return node.render(context)
File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/newrelic-1.2.0.246/newrelic/hooks/framework_django.py", line 622, in __call__
return self.__wrapped(*args, **kwargs)
File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/loader_tags.py", line 64, in render
result = block.nodelist.render(context)
File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/base.py", line 744, in render
bits.append(self.render_node(node, context))
File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/base.py", line 757, in render_node
return node.render(context)
File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/defaulttags.py", line 311, in render
return self.nodelist_true.render(context)
File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/base.py", line 744, in render
bits.append(self.render_node(node, context))
File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/base.py", line 757, in render_node
return node.render(context)
File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/defaulttags.py", line 227, in render
nodelist.append(node.render(context))
File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/base.py", line 915, in render
resolved_vars = [var.resolve(context) for var in self.vars_to_resolve]
File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/base.py", line 653, in resolve
value = self._resolve_lookup(context)
File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/base.py", line 692, in _resolve_lookup
raise VariableDoesNotExist("Failed lookup for key [%s] in %r", (bit, current)) # missing attribute
VariableDoesNotExist: Failed lookup for key [object] in u'None'
<WSGIRequest
GET:<QueryDict: {u'q': [u'stockholm']}>,

Could you please put here your view and your template code? If this is happening with just some queries and not all of them, it could be the parameters you are passing to the view.
Here's the code of the view I'm using to make search queries using Haystack 2.0 and Whoosh 2.3.2 in a project of my own:
def search(request):
sqs = SearchQuerySet().filter(content=AutoQuery(request.GET['q']))
return render_to_response('search.html', {'sqs': sqs,})
and this works perfectly fine. I guess you should consider using the latest version of Haystack, because I was experiencing a lot of bugs with the old stable ones. And I recommend you to use the "rebuild_index" once in a while too, just in case.

Related

Django throws datetime.datetime has no attribute encode error when activating admin site

When setting up the Django admin site, I get the following error. I am having a hard time debugging it because I can't tell where in my 'Announcement' model the problem is occurring. I've checked base.py on the line where the problem occurs, but I don't really understand all of what is going on in that class.
Internal Server Error: /admin/main/announcment/
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 140, in get_response
response = response.render()
File "/usr/local/lib/python2.7/dist-packages/django/template/response.py", line 105, in render
self.content = self.rendered_content
File "/usr/local/lib/python2.7/dist-packages/django/template/response.py", line 82, in rendered_content
content = template.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 140, in render
return self._render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 134, in _render
return self.nodelist.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 830, in render
bit = self.render_node(node, context)
File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py", line 74, in render_node
return node.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/loader_tags.py", line 124, in render
return compiled_parent._render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 134, in _render
return self.nodelist.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 830, in render
bit = self.render_node(node, context)
File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py", line 74, in render_node
return node.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/loader_tags.py", line 124, in render
return compiled_parent._render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 134, in _render
return self.nodelist.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 830, in render
bit = self.render_node(node, context)
File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py", line 74, in render_node
return node.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/loader_tags.py", line 63, in render
result = block.nodelist.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 830, in render
bit = self.render_node(node, context)
File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py", line 74, in render_node
return node.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/loader_tags.py", line 63, in render
result = block.nodelist.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 830, in render
bit = self.render_node(node, context)
File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py", line 74, in render_node
return node.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 1185, in render
_dict = func(*resolved_args, **resolved_kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/templatetags/admin_list.py", line 286, in result_list
'results': list(results(cl))}
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/templatetags/admin_list.py", line 264, in results
yield ResultList(None, items_for_result(cl, res, None))
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/templatetags/admin_list.py", line 256, in __init__
super(ResultList, self).__init__(*items)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/templatetags/admin_list.py", line 184, in items_for_result
f, attr, value = lookup_field(field_name, result, cl.model_admin)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/util.py", line 258, in lookup_field
value = attr()
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 433, in __str__
return force_text(self).encode('utf-8')
AttributeError: 'datetime.datetime' object has no attribute 'encode'
Without seeing your Annoucement model, it's hard to tell, but it seems probable that you are returning a datetime from your __unicode__ method, instead of an actual unicode string.

"DoesNotExist: ContentType matching query does not exist" only happens occassionally

Pretty simple code but a weird situation...
have a template with this snippet:
{% is_contest story as iscontest %}
where is_contest is this custom template tag:
#register.assignment_tag
def is_contest(obj):
contesttype = ContentType.objects.get_for_model(Contest)
return obj.source_content_type == contesttype
But Contest is in the django_content_type table.
Weirdest part: This is only an intermittent error, and only seems to be caused by the template tag (I do this check in views too but no errors there).
Any ideas?
EDIT: Full Traceback
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 111, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "/home/ubuntu/src/cbframe/commentableobjects/views/commentableobject_list.py", line 142, in commentablobject_list
return render_to_response('commentableobjects-list.html', info, context_instance=RequestContext(request))
File "/usr/local/lib/python2.7/dist-packages/django/shortcuts/__init__.py", line 20, in render_to_response
return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/template/loader.py", line 176, in render_to_string
return t.render(context_instance)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 140, in render
return self._render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 134, in _render
return self.nodelist.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 823, in render
bit = self.render_node(node, context)
File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py", line 74, in render_node
return node.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/loader_tags.py", line 123, in render
return compiled_parent._render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 134, in _render
return self.nodelist.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 823, in render
bit = self.render_node(node, context)
File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py", line 74, in render_node
return node.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/loader_tags.py", line 62, in render
result = block.nodelist.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 823, in render
bit = self.render_node(node, context)
File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py", line 74, in render_node
return node.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/defaulttags.py", line 281, in render
return nodelist.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 823, in render
bit = self.render_node(node, context)
File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py", line 74, in render_node
return node.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/loader_tags.py", line 155, in render
return self.render_template(self.template, context)
File "/usr/local/lib/python2.7/dist-packages/django/template/loader_tags.py", line 137, in render_template
output = template.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 140, in render
return self._render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 134, in _render
return self.nodelist.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 823, in render
bit = self.render_node(node, context)
File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py", line 74, in render_node
return node.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/defaulttags.py", line 185, in render
nodelist.append(node.render(context))
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 1139, in render
context[self.target_var] = func(*resolved_args, **resolved_kwargs)
File "/home/ubuntu/src/cbframe/commentableobjects/templatetags/url_target_blank.py", line 27, in is_contest
return obj.source_content_type == contesttype
File "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/related.py", line 350, in __get__
rel_obj = qs.get(**params)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 366, in get
% self.model._meta.object_name)
DoesNotExist: ContentType matching query does not exist.
One problem might be that you are comparing 2 instances with eachother, while these should be the same in Django since Django caches them, that is not a guarantee.
Not sure how/where the source_content_type comes from, but I would recommend this instead:
return isinstance(obj, contesttype)
As for the original problem, do you have a stacktrace? This error seems a bit strange.
Are you sure that Contest isn't being overwritten somewhere in the scope?
Contest could be overwritten by other code in the module, the most likely suspect in that case would be a global Contest but that doesn't appear to be the case here.
[edit]
Thanks to the stacktrace the problem is a bit clearer.
This part specifically shows that it's going wrong in the obj.source_content_type part:
return obj.source_content_type == contesttype
I think that some object doesn't have an existing source_content_type anymore.

Django Search Query Fails

I've implemented this search feature on a small site I'm working on and I am having problems when I carry out a search query. This is the traceback:
Traceback (most recent call last):
File "/Users/glosseyvilly/Desktop/web_dev/ccdev/lib/python2.6/site-packages/django/contrib/staticfiles/handlers.py", line 68, in __call__
return self.application(environ, start_response)
File "/Users/glosseyvilly/Desktop/web_dev/ccdev/lib/python2.6/site-packages/django/contrib/staticfiles/handlers.py", line 68, in __call__
return self.application(environ, start_response)
File "/Users/glosseyvilly/Desktop/web_dev/ccdev/lib/python2.6/site-packages/django/core/handlers/wsgi.py", line 272, in __call__
response = self.get_response(request)
File "/Users/glosseyvilly/Desktop/web_dev/ccdev/lib/python2.6/site-packages/django/core/handlers/base.py", line 169, in get_response
response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
File "/Users/glosseyvilly/Desktop/web_dev/ccdev/lib/python2.6/site-packages/django/core/handlers/base.py", line 203, in handle_uncaught_exception
return debug.technical_500_response(request, *exc_info)
File "/Users/glosseyvilly/Desktop/web_dev/ccdev/lib/python2.6/site-packages/django/core/handlers/base.py", line 111, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "/Users/glosseyvilly/PycharmProjects/first_django_dev/apps/photos/views.py", line 113, in search_photos
'search_query': search_query
File "/Users/glosseyvilly/Desktop/web_dev/ccdev/lib/python2.6/site-packages/django/shortcuts/__init__.py", line 44, in render
return HttpResponse(loader.render_to_string(*args, **kwargs),
File "/Users/glosseyvilly/Desktop/web_dev/ccdev/lib/python2.6/site-packages/django/template/loader.py", line 188, in render_to_string
return t.render(context_instance)
File "/Users/glosseyvilly/Desktop/web_dev/ccdev/lib/python2.6/site-packages/django/template/base.py", line 123, in render
return self._render(context)
File "/Users/glosseyvilly/Desktop/web_dev/ccdev/lib/python2.6/site-packages/django/template/base.py", line 117, in _render
return self.nodelist.render(context)
File "/Users/glosseyvilly/Desktop/web_dev/ccdev/lib/python2.6/site-packages/django/template/base.py", line 744, in render
bits.append(self.render_node(node, context))
File "/Users/glosseyvilly/Desktop/web_dev/ccdev/lib/python2.6/site-packages/django/template/debug.py", line 73, in render_node
result = node.render(context)
File "/Users/glosseyvilly/Desktop/web_dev/ccdev/lib/python2.6/site-packages/django/template/loader_tags.py", line 127, in render
return compiled_parent._render(context)
File "/Users/glosseyvilly/Desktop/web_dev/ccdev/lib/python2.6/site-packages/django/template/base.py", line 117, in _render
return self.nodelist.render(context)
File "/Users/glosseyvilly/Desktop/web_dev/ccdev/lib/python2.6/site-packages/django/template/base.py", line 744, in render
bits.append(self.render_node(node, context))
File "/Users/glosseyvilly/Desktop/web_dev/ccdev/lib/python2.6/site-packages/django/template/debug.py", line 73, in render_node
result = node.render(context)
File "/Users/glosseyvilly/Desktop/web_dev/ccdev/lib/python2.6/site-packages/django/template/loader_tags.py", line 64, in render
result = block.nodelist.render(context)
File "/Users/glosseyvilly/Desktop/web_dev/ccdev/lib/python2.6/site-packages/django/template/base.py", line 744, in render
bits.append(self.render_node(node, context))
File "/Users/glosseyvilly/Desktop/web_dev/ccdev/lib/python2.6/site-packages/django/template/debug.py", line 73, in render_node
result = node.render(context)
File "/Users/glosseyvilly/Desktop/web_dev/ccdev/lib/python2.6/site-packages/django/template/defaulttags.py", line 311, in render
return self.nodelist_true.render(context)
File "/Users/glosseyvilly/Desktop/web_dev/ccdev/lib/python2.6/site-packages/django/template/base.py", line 744, in render
bits.append(self.render_node(node, context))
File "/Users/glosseyvilly/Desktop/web_dev/ccdev/lib/python2.6/site-packages/django/template/debug.py", line 73, in render_node
result = node.render(context)
File "/Users/glosseyvilly/Desktop/web_dev/ccdev/lib/python2.6/site-packages/django/template/defaulttags.py", line 227, in render
nodelist.append(node.render(context))
File "/Users/glosseyvilly/Desktop/web_dev/ccdev/lib/python2.6/site-packages/django/template/base.py", line 915, in render
resolved_vars = [var.resolve(context) for var in self.vars_to_resolve]
File "/Users/glosseyvilly/Desktop/web_dev/ccdev/lib/python2.6/site-packages/django/template/base.py", line 653, in resolve
value = self._resolve_lookup(context)
File "/Users/glosseyvilly/Desktop/web_dev/ccdev/lib/python2.6/site-packages/django/template/base.py", line 692, in _resolve_lookup
raise VariableDoesNotExist("Failed lookup for key [%s] in %r", (bit, current)) # missing attribute
TemplateSyntaxError: Caught VariableDoesNotExist while rendering: Failed lookup for key [user] in u"'uploaded_photos/Published/2011/December/21/image_5.jpeg'"
This is my view function:
def search_photos(request):
"""
"""
search_query = ''
results = None
if ('q' in request.GET) and request.GET['q'].strip():
search_query = request.GET['q']
photo_query = get_query(search_query, ['caption',])
results = Photo.objects.filter(photo_query).order_by('-date_added')
return render(request, 'photos/search.html', {
'results': results,
'search_query': search_query
})
NB: The traceback highlights 'search_query': search_query being a possible error and I'm not sure why.
EDIT: Here is a link to my search.html template : gist.github.com/1524911
You need to format the error message as a code block.
The specific error is at the end of the traceback: Failed lookup for key [user] in u"'uploaded_photos/Published/2011/December/21/image_5.jpeg'" which occurred in _resolve_lookup. This is the routine that does the variable value fetching for templates.
I would take a hard look at the template. Pay special attention to any tricky loop references or template tags that might be doing strange lookups (e.g {% expr %} comes to mind). Let us know what you come up with.
Update:
My money is on the line:
{% phileo_widget result.user result %}
Does the result object have an attribute named user?
Shouldn't your method take self as its first parameter?:
def search_photos(self):
So, you access the request object with:
request = self.request

Django SSL error

I seem to get this error, and don't know how to debug it.
Any pointers?
Traceback (most recent call last):
File "/opt/python2.6/lib/python2.6/site-packages/django/core/handlers/base.py", line 92, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "/www/django_test1/omu2/views.py", line 26, in frontIndex
context_instance=RequestContext(request))
File "/opt/python2.6/lib/python2.6/site-packages/django/shortcuts/__init__.py", line 20, in render_to_response
return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
File "/opt/python2.6/lib/python2.6/site-packages/django/template/loader.py", line 108, in render_to_string
return t.render(context_instance)
File "/opt/python2.6/lib/python2.6/site-packages/django/template/__init__.py", line 178, in render
return self.nodelist.render(context)
File "/opt/python2.6/lib/python2.6/site-packages/django/template/__init__.py", line 779, in render
bits.append(self.render_node(node, context))
File "/opt/python2.6/lib/python2.6/site-packages/django/template/__init__.py", line 792, in render_node
return node.render(context)
File "/opt/python2.6/lib/python2.6/site-packages/django/template/loader_tags.py", line 97, in render
return compiled_parent.render(context)
File "/opt/python2.6/lib/python2.6/site-packages/django/template/__init__.py", line 178, in render
return self.nodelist.render(context)
File "/opt/python2.6/lib/python2.6/site-packages/django/template/__init__.py", line 779, in render
bits.append(self.render_node(node, context))
File "/opt/python2.6/lib/python2.6/site-packages/django/template/__init__.py", line 792, in render_node
return node.render(context)
File "/opt/python2.6/lib/python2.6/site-packages/django/template/loader_tags.py", line 24, in render
result = self.nodelist.render(context)
File "/opt/python2.6/lib/python2.6/site-packages/django/template/__init__.py", line 779, in render
bits.append(self.render_node(node, context))
File "/opt/python2.6/lib/python2.6/site-packages/django/template/__init__.py", line 792, in render_node
return node.render(context)
File "/opt/python2.6/lib/python2.6/site-packages/django/template/__init__.py", line 946, in render
autoescape=context.autoescape))
File "/opt/python2.6/lib/python2.6/site-packages/django/template/__init__.py", line 779, in render
bits.append(self.render_node(node, context))
File "/opt/python2.6/lib/python2.6/site-packages/django/template/__init__.py", line 792, in render_node
return node.render(context)
File "/opt/python2.6/lib/python2.6/site-packages/django/template/defaulttags.py", line 243, in render
return self.nodelist_true.render(context)
File "/opt/python2.6/lib/python2.6/site-packages/django/template/__init__.py", line 779, in render
bits.append(self.render_node(node, context))
File "/opt/python2.6/lib/python2.6/site-packages/django/template/__init__.py", line 792, in render_node
return node.render(context)
File "/opt/python2.6/lib/python2.6/site-packages/django/template/defaulttags.py", line 155, in render
nodelist.append(node.render(context))
File "/opt/python2.6/lib/python2.6/site-packages/django/template/__init__.py", line 826, in render
output = self.filter_expression.resolve(context)
File "/opt/python2.6/lib/python2.6/site-packages/django/template/__init__.py", line 546, in resolve
obj = self.var.resolve(context)
File "/opt/python2.6/lib/python2.6/site-packages/django/template/__init__.py", line 687, in resolve
value = self._resolve_lookup(context)
File "/opt/python2.6/lib/python2.6/site-packages/django/template/__init__.py", line 716, in _resolve_lookup
current = getattr(current, bit)
File "/opt/python2.6/lib/python2.6/site-packages/django_imagekit-0.3.3-py2.6.egg/imagekit/specs.py", line 94, in url
self._create()
File "/opt/python2.6/lib/python2.6/site-packages/django_imagekit-0.3.3-py2.6.egg/imagekit/specs.py", line 66, in _create
self._obj._storage.save(self.name, content)
File "/opt/python2.6/lib/python2.6/site-packages/django/core/files/storage.py", line 46, in save
name = self.get_available_name(name)
File "/opt/python2.6/lib/python2.6/site-packages/django/core/files/storage.py", line 71, in get_available_name
while self.exists(name):
File "/opt/python2.6/lib/python2.6/site-packages/cumulus/storage.py", line 147, in exists
self._get_cloud_obj(name)
File "/opt/python2.6/lib/python2.6/site-packages/cumulus/storage.py", line 99, in _get_cloud_obj
return self.container.get_object(name)
File "/www/django_test1/omu2/src/python-cloudfiles/cloudfiles/utils.py", line 43, in decorator
return f(*args, **kwargs)
File "/www/django_test1/omu2/src/python-cloudfiles/cloudfiles/container.py", line 316, in get_object
return Object(self, object_name, force_exists=True)
File "/www/django_test1/omu2/src/python-cloudfiles/cloudfiles/storage_object.py", line 89, in __init__
if not self._initialize() and force_exists:
File "/www/django_test1/omu2/src/python-cloudfiles/cloudfiles/storage_object.py", line 462, in _initialize
'HEAD', [self.container.name, self.name]
File "/www/django_test1/omu2/src/python-cloudfiles/cloudfiles/connection.py", line 200, in make_request
response = retry_request()
File "/www/django_test1/omu2/src/python-cloudfiles/cloudfiles/connection.py", line 194, in retry_request
return self.connection.getresponse()
File "/opt/python2.6/lib/python2.6/httplib.py", line 974, in getresponse
response.begin()
File "/opt/python2.6/lib/python2.6/httplib.py", line 391, in begin
version, status, reason = self._read_status()
File "/opt/python2.6/lib/python2.6/httplib.py", line 349, in _read_status
line = self.fp.readline()
File "/opt/python2.6/lib/python2.6/socket.py", line 397, in readline
data = recv(1)
File "/opt/python2.6/lib/python2.6/ssl.py", line 96, in <lambda>
self.recv = lambda buflen=1024, flags=0: SSLSocket.recv(self, buflen, flags)
File "/opt/python2.6/lib/python2.6/ssl.py", line 222, in recv
raise x
SSLError: The read operation timed out
I'm the author of django-cumulus. Cloud Files is notorious for SSL connection issues. django-cumulus has a setting (added in 0.3.6) called CUMULUS_TIMEOUT that defaults to 5 seconds. You can increase it to 10 or 15 to try and alleviate this.
See https://github.com/richleland/django-cumulus/issues/5 for more info and feel free to post an issue there if you continue to experience problems.
From the look of it I would say that the connection to Rackspace Cloudfiles timed out. Imagekit builds the thumbnails dynamically (which I believe it was doing here in _create()) but there is also an option to create all the thumbnails when the model is saved as opposed to while rendering. That won't really help you if Rackspace goes down but it will help lower the time it takes to render your templates.
EDIT:
To pre-cache your thumbnail you change your ImageSpec definition to include pre_cache = True such as (from the imagekit wiki):
from imagekit.specs import ImageSpec
class Thumbnail(ImageSpec):
access_as = 'thumbnail_image'
pre_cache = True
If you change your specs you can re-build all of the cached thumbnails with the ikflush management command. You should note that while this will create all the thumbnails where pre_cache = True this will also delete all the cached images where pre_cache = False.

Django imagekit cumulus - ResponseError: 401: Unauthorized

This is driving me crazy.
Is there someone out there that can help?
Traceback (most recent call last):
File "/opt/python2.6/lib/python2.6/site-packages/django/core/handlers/base.py", line 92, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "/www/django_test1/omu2/views.py", line 26, in frontIndex
context_instance=RequestContext(request))
File "/opt/python2.6/lib/python2.6/site-packages/django/shortcuts/__init__.py", line 20, in render_to_response
return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
File "/opt/python2.6/lib/python2.6/site-packages/django/template/loader.py", line 108, in render_to_string
return t.render(context_instance)
File "/opt/python2.6/lib/python2.6/site-packages/django/template/__init__.py", line 178, in render
return self.nodelist.render(context)
File "/opt/python2.6/lib/python2.6/site-packages/django/template/__init__.py", line 779, in render
bits.append(self.render_node(node, context))
File "/opt/python2.6/lib/python2.6/site-packages/django/template/__init__.py", line 792, in render_node
return node.render(context)
File "/opt/python2.6/lib/python2.6/site-packages/django/template/loader_tags.py", line 97, in render
return compiled_parent.render(context)
File "/opt/python2.6/lib/python2.6/site-packages/django/template/__init__.py", line 178, in render
return self.nodelist.render(context)
File "/opt/python2.6/lib/python2.6/site-packages/django/template/__init__.py", line 779, in render
bits.append(self.render_node(node, context))
File "/opt/python2.6/lib/python2.6/site-packages/django/template/__init__.py", line 792, in render_node
return node.render(context)
File "/opt/python2.6/lib/python2.6/site-packages/django/template/loader_tags.py", line 24, in render
result = self.nodelist.render(context)
File "/opt/python2.6/lib/python2.6/site-packages/django/template/__init__.py", line 779, in render
bits.append(self.render_node(node, context))
File "/opt/python2.6/lib/python2.6/site-packages/django/template/__init__.py", line 792, in render_node
return node.render(context)
File "/opt/python2.6/lib/python2.6/site-packages/django/template/__init__.py", line 946, in render
autoescape=context.autoescape))
File "/opt/python2.6/lib/python2.6/site-packages/django/template/__init__.py", line 779, in render
bits.append(self.render_node(node, context))
File "/opt/python2.6/lib/python2.6/site-packages/django/template/__init__.py", line 792, in render_node
return node.render(context)
File "/opt/python2.6/lib/python2.6/site-packages/django/template/defaulttags.py", line 243, in render
return self.nodelist_true.render(context)
File "/opt/python2.6/lib/python2.6/site-packages/django/template/__init__.py", line 779, in render
bits.append(self.render_node(node, context))
File "/opt/python2.6/lib/python2.6/site-packages/django/template/__init__.py", line 792, in render_node
return node.render(context)
File "/opt/python2.6/lib/python2.6/site-packages/django/template/defaulttags.py", line 155, in render
nodelist.append(node.render(context))
File "/opt/python2.6/lib/python2.6/site-packages/django/template/__init__.py", line 826, in render
output = self.filter_expression.resolve(context)
File "/opt/python2.6/lib/python2.6/site-packages/django/template/__init__.py", line 546, in resolve
obj = self.var.resolve(context)
File "/opt/python2.6/lib/python2.6/site-packages/django/template/__init__.py", line 687, in resolve
value = self._resolve_lookup(context)
File "/opt/python2.6/lib/python2.6/site-packages/django/template/__init__.py", line 716, in _resolve_lookup
current = getattr(current, bit)
File "/opt/python2.6/lib/python2.6/site-packages/django_imagekit-0.3.3-py2.6.egg/imagekit/specs.py", line 94, in url
self._create()
File "/opt/python2.6/lib/python2.6/site-packages/django_imagekit-0.3.3-py2.6.egg/imagekit/specs.py", line 54, in _create
if self._exists():
File "/opt/python2.6/lib/python2.6/site-packages/django_imagekit-0.3.3-py2.6.egg/imagekit/specs.py", line 72, in _exists
return self._obj._storage.exists(self.name)
File "/opt/python2.6/lib/python2.6/site-packages/cumulus/storage.py", line 147, in exists
self._get_cloud_obj(name)
File "/opt/python2.6/lib/python2.6/site-packages/cumulus/storage.py", line 99, in _get_cloud_obj
return self.container.get_object(name)
File "/www/django_test1/omu2/src/python-cloudfiles/cloudfiles/utils.py", line 43, in decorator
return f(*args, **kwargs)
File "/www/django_test1/omu2/src/python-cloudfiles/cloudfiles/container.py", line 316, in get_object
return Object(self, object_name, force_exists=True)
File "/www/django_test1/omu2/src/python-cloudfiles/cloudfiles/storage_object.py", line 89, in __init__
if not self._initialize() and force_exists:
File "/www/django_test1/omu2/src/python-cloudfiles/cloudfiles/storage_object.py", line 468, in _initialize
raise ResponseError(response.status, response.reason)
ResponseError: 401: Unauthorized
Ok, so I have done a bit of digging and fond that django-1.1.1, django-imagekit-0.3.3 and django-cumulus-0.3.3 or earlier versions don't play well together.
I upgraded to django-1.1.2 django-cumulus-0.3.4 and works fine now.
to do this do the following - pip install -r http://bitbucket.org/richleland/django-cumulus/raw/0.3.4/requirements.txt