-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviews.py
More file actions
60 lines (43 loc) · 1.39 KB
/
views.py
File metadata and controls
60 lines (43 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from django.shortcuts import render
# Create your views here.
# from django.http import HttpResponse
from django.shortcuts import render
from myapp.models import Task
def home(request):
return render(request, 'home.html')
def index(request):
context = {'success': False}
if request.method == "POST":
title = request.POST['title']
desc = request.POST['desc']
print(title, desc)
ins = Task(note_title=title, note_description=desc)
ins.save()
context = {'success': True}
return render(request, 'index.html', context)
def tasks(request):
allTasks = Task.objects.all()
print(allTasks)
context = {'tasks': allTasks}
return render(request, 'tasks.html', context)
def list(request):
mydictionary = {
"allTasks": Task.objects.all()
}
return render(request, 'list.html', context=mydictionary)
def delete(request, id):
obj = Task.objects.get(id=id)
obj.delete()
mydictionary = {
"allTasks": Task.objects.all()
}
return render(request, 'list.html', context=mydictionary)
def edit(request, id):
obj = Task.objects.get(id=id)
mydictionary = {
"title": obj.title,
"desc": obj.description,
"priority": obj.priority,
"id": obj.id
}
return render(request, 'edit.html', context=mydictionary)