diff --git a/people/views.py b/people/views.py index 36c7b6e..56a71b0 100644 --- a/people/views.py +++ b/people/views.py @@ -1,4 +1,5 @@ from django.contrib.auth.decorators import login_required +from django.core import serializers from django.db.models import Q from django.http import Http404, HttpResponseRedirect, HttpResponseBadRequest, JsonResponse from django.shortcuts import render @@ -16,8 +17,8 @@ def get_people(people_id: int) -> People: def index(request): - return render(request, "people/personnes.html", { - "personnes": People.objects.all() + return render(request, "people/peoples.html", { + "peoples": People.objects.all() }) @@ -62,4 +63,4 @@ def edit(request, people_id: int): def ajax_search(request, text: str): - return JsonResponse(People.objects.filter(Q(first_name__icontains=text) | Q(first_name__icontains=text))) + return JsonResponse(serializers.serialize("json", People.objects.filter(Q(first_name__icontains=text) | Q(first_name__icontains=text))), safe=False) diff --git a/templates/people/peoples.html b/templates/people/peoples.html new file mode 100644 index 0000000..77aa943 --- /dev/null +++ b/templates/people/peoples.html @@ -0,0 +1,28 @@ +{% extends 'base.html' %} +{% load static %} +{% block content %} + + + + Sauvetages + + {% for people in peoples %} + + + + + + + + + {{ people }} + Voir la personne + + + + + {% endfor %} + + Charger plus de personnes + + {% include 'quicksearch.html' %} +{% endblock %} \ No newline at end of file
{{ people }}