Skip to content

Commit

Permalink
Update views.py
Browse files Browse the repository at this point in the history
  • Loading branch information
pierreNomazy committed Oct 28, 2015
1 parent 064b892 commit 4a6a5ec
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lfs/search/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.template.loader import render_to_string
from django.utils import simplejson
import json

# lfs imports
from lfs.catalog.models import Category
Expand All @@ -20,13 +20,13 @@ def livesearch(request, template_name="lfs/search/livesearch_results.html"):
q = request.GET.get("q", "")

if q == "":
result = simplejson.dumps({
result = json.dumps({
"state": "failure",
})
else:
# Products
query = Q(active=True) & get_query(q, ['name', 'description'])
temp = Product.objects.filter(query)
temp = Product.objects.filter(query)
if not temp:
# Creates a SearchNotFound for the current session and/or user.
if request.session.session_key is None:
Expand All @@ -46,11 +46,11 @@ def livesearch(request, template_name="lfs/search/livesearch_results.html"):
"total": total,
}))

result = simplejson.dumps({
result = json.dumps({
"state": "success",
"products": products,
})
return HttpResponse(result, mimetype='application/json')
return HttpResponse(result, content_type='application/json')


def search(request, template_name="lfs/search/search_results.html"):
Expand Down

1 comment on commit 4a6a5ec

@pierreNomazy
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct json / simplejson and content_type/ mimetype

Please sign in to comment.