1. Kai Diefenbach
  2. django-lfs

Commits

Radim Novotny  committed 145a5ae

Don't fail of sorting contains unsupported values. This is case of switching lfs_solr on/off only

  • Participants
  • Parent commits 23a4457
  • Branches default

Comments (0)

Files changed (1)

File lfs/search/views.py

View file
 # django imports
 from django.db.models import Q
+from django.core.exceptions import FieldError
 from django.http import HttpResponse
 from django.shortcuts import render_to_response
 from django.template import RequestContext
     # Sorting
     sorting = request.session.get("sorting")
     if sorting:
-        products = products.order_by(sorting)
+        try:
+            products = products.order_by(sorting)
+        except FieldError:
+            # this should not happen but I experienced it when
+            # switching on/off lfs_solr which uses different
+            # field specification for sorting but the same session key
+            del request.session["sorting"]
 
     total = 0
     if products:
         "products": products,
         "q": q,
         "total": total,
-    }))
+    }))