forked from DGNum/gestioCOF
Utilisation des JsonResponse
This commit is contained in:
parent
c4a3c1a92a
commit
a9c8de7544
1 changed files with 4 additions and 4 deletions
|
@ -17,7 +17,7 @@ from django.core import serializers
|
|||
from django.db.models import Count, Q, Sum
|
||||
from django.forms.models import inlineformset_factory
|
||||
from django.http import HttpResponseBadRequest, HttpResponseRedirect,\
|
||||
HttpResponse
|
||||
JsonResponse, HttpResponse
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.conf import settings
|
||||
from django.utils import timezone, formats
|
||||
|
@ -656,7 +656,7 @@ def catalogue(request, request_type):
|
|||
{'id': tirage.id, 'title': tirage.title}
|
||||
for tirage in Tirage.objects.filter(appear_catalogue=True).all()
|
||||
]
|
||||
return HttpResponse(json.dumps(data_return))
|
||||
return JsonResponse(data_return, safe=False)
|
||||
if request_type == "details":
|
||||
# Dans ce cas on retourne une liste des catégories et des salles
|
||||
try:
|
||||
|
@ -674,7 +674,7 @@ def catalogue(request, request_type):
|
|||
for spectacle in tirage.spectacle_set.all()
|
||||
]))
|
||||
data_return = [{'categories': categories, 'locations': locations}]
|
||||
return HttpResponse(json.dumps(data_return))
|
||||
return JsonResponse(data_return, safe=False)
|
||||
if request_type == "descriptions":
|
||||
# Ici on retourne les descriptions correspondant à la catégorie et
|
||||
# à la salle spécifiées
|
||||
|
@ -733,6 +733,6 @@ def catalogue(request, request_type):
|
|||
}
|
||||
for spectacle in shows_qs.all()
|
||||
]
|
||||
return HttpResponse(json.dumps(data_return))
|
||||
return JsonResponse(data_return, safe=False)
|
||||
# Si la requête n'est pas de la forme attendue, on quitte avec une erreur
|
||||
return HttpResponseBadRequest()
|
||||
|
|
Loading…
Reference in a new issue