finished the front for the task manager
This commit is contained in:
0
back/testapp/__init__.py
Normal file
0
back/testapp/__init__.py
Normal file
BIN
back/testapp/__pycache__/__init__.cpython-312.pyc
Normal file
BIN
back/testapp/__pycache__/__init__.cpython-312.pyc
Normal file
Binary file not shown.
BIN
back/testapp/__pycache__/admin.cpython-312.pyc
Normal file
BIN
back/testapp/__pycache__/admin.cpython-312.pyc
Normal file
Binary file not shown.
BIN
back/testapp/__pycache__/apps.cpython-312.pyc
Normal file
BIN
back/testapp/__pycache__/apps.cpython-312.pyc
Normal file
Binary file not shown.
BIN
back/testapp/__pycache__/models.cpython-312.pyc
Normal file
BIN
back/testapp/__pycache__/models.cpython-312.pyc
Normal file
Binary file not shown.
BIN
back/testapp/__pycache__/urls.cpython-312.pyc
Normal file
BIN
back/testapp/__pycache__/urls.cpython-312.pyc
Normal file
Binary file not shown.
BIN
back/testapp/__pycache__/views.cpython-312.pyc
Normal file
BIN
back/testapp/__pycache__/views.cpython-312.pyc
Normal file
Binary file not shown.
3
back/testapp/admin.py
Normal file
3
back/testapp/admin.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
5
back/testapp/apps.py
Normal file
5
back/testapp/apps.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class TestappConfig(AppConfig):
|
||||
name = 'testapp'
|
||||
23
back/testapp/migrations/0001_initial.py
Normal file
23
back/testapp/migrations/0001_initial.py
Normal file
@@ -0,0 +1,23 @@
|
||||
# Generated by Django 6.0.2 on 2026-02-21 15:43
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='task',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('task_text', models.CharField(max_length=1024)),
|
||||
('pub_date', models.DateTimeField(verbose_name='date published')),
|
||||
('done', models.BooleanField(default=False)),
|
||||
],
|
||||
),
|
||||
]
|
||||
0
back/testapp/migrations/__init__.py
Normal file
0
back/testapp/migrations/__init__.py
Normal file
BIN
back/testapp/migrations/__pycache__/0001_initial.cpython-312.pyc
Normal file
BIN
back/testapp/migrations/__pycache__/0001_initial.cpython-312.pyc
Normal file
Binary file not shown.
BIN
back/testapp/migrations/__pycache__/__init__.cpython-312.pyc
Normal file
BIN
back/testapp/migrations/__pycache__/__init__.cpython-312.pyc
Normal file
Binary file not shown.
9
back/testapp/models.py
Normal file
9
back/testapp/models.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
|
||||
class Task (models.Model) :
|
||||
task_text = models.CharField(max_length=1024)
|
||||
pub_date = models.DateTimeField("date published")
|
||||
done = models.BooleanField(default=False)
|
||||
|
||||
3
back/testapp/tests.py
Normal file
3
back/testapp/tests.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
6
back/testapp/urls.py
Normal file
6
back/testapp/urls.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from django.urls import path
|
||||
from .views import getAllTasks
|
||||
|
||||
urlpatterns = [
|
||||
path("getAllTasks", getAllTasks, name="api_view")
|
||||
]
|
||||
36
back/testapp/views.py
Normal file
36
back/testapp/views.py
Normal 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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user