finished the front for the task manager

This commit is contained in:
celeste
2026-03-01 14:04:21 +01:00
parent 8c368f3c8e
commit 358df6e0bd
66 changed files with 1319 additions and 179 deletions

36
back/testapp/views.py Normal file
View File

@@ -0,0 +1,36 @@
from django.shortcuts import render
from django.http import JsonResponse
import json
from datetime import datetime
from .models import Task
# Create your views here.
from django.forms.models import model_to_dict
from rest_framework.response import Response
from rest_framework.decorators import api_view
@api_view(['GET'])
def getAllTasks(request, *args, **kwargs) :
#data = json.loads(request.body)
#print(data)
#data = {"salutation":"wsh wsh "+data["name"]}
#return JsonResponse(data)
query = Task.objects.all().order_by("?")
print("query : ", query)
data = {"data" : []}
if query and len(query) > 0 :
for q in query :
sub_data = {}
sub_data["text"] = q.task_text
sub_data["pub date"] = q.pub_date.strftime('%m/%d/%Y at %H')
sub_data["done"] = q.done
data["data"].append(sub_data)
#equivalent à model_to_dict
return Response(data)