28 lines
959 B
Python
28 lines
959 B
Python
from django.db import models
|
|
from django.contrib.auth.models import User
|
|
|
|
class Task(models.Model):
|
|
PRIORITY_CHOICES = [
|
|
('low', 'Low'),
|
|
('medium', 'Medium'),
|
|
('high', 'High'),
|
|
]
|
|
|
|
STATUS_CHOICES = [
|
|
('pending', 'Pending'),
|
|
('in_progress', 'In Progress'),
|
|
('completed', 'Completed'),
|
|
('missed', 'Missed'),
|
|
]
|
|
|
|
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name="tasks")
|
|
title = models.CharField(max_length=200)
|
|
description = models.TextField(blank=True, null=True)
|
|
priority = models.CharField(max_length=10, choices=PRIORITY_CHOICES, default='medium')
|
|
status = models.CharField(max_length=20, choices=STATUS_CHOICES, default='pending')
|
|
due_date = models.DateField(blank=True, null=True)
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
updated_at = models.DateTimeField(auto_now=True)
|
|
|
|
def __str__(self):
|
|
return self.title |