Currently I am trying to make a task management site which i can add and remove tasks on. Currently to add a task i have to go through admin console Please assist
Code from views.py:
from django.http import HttpResponse
from .models import Task
import datetime
from django.db import models
from django.utils import timezone
from django.template import loader
def tasks(request):
latest_task = Task.objects.order_by("-publish_date")[:5]
template = loader.get_template("tasks/index.html")
context = {
"latest_task": latest_task,
}
return HttpResponse(template.render(context, request))
Code from models.py:
from django.db import models
class Task(models.Model):
task = models.CharField(max_length=100)
publish_date = models.DateTimeField("Date Pulished")
def __str__(self):
return self.task