zkt26/z1/diary/models.py
2026-04-01 06:53:48 +02:00

28 lines
903 B
Python

from django.db import models
from django.contrib.auth.models import User
MOOD_CHOICES = [
('happy', '😊 Happy'),
('sad', '😢 Sad'),
('anxious', '😰 Anxious'),
('calm', '😌 Calm'),
('excited', '🤩 Excited'),
('angry', '😠 Angry'),
('grateful', '🙏 Grateful'),
('tired', '😴 Tired'),
]
class Entry(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='entries')
title = models.CharField(max_length=200)
content = models.TextField()
mood = models.CharField(max_length=20, choices=MOOD_CHOICES, default='calm')
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
class Meta:
ordering = ['-created_at']
def __str__(self):
return f"{self.title} ({self.created_at.strftime('%Y-%m-%d')})"