Django-NotesApp/project/notes/models.py

16 lines
466 B
Python
Raw Permalink Normal View History

2023-02-24 00:13:44 +08:00
from django.db import models
from django.utils.timezone import now
2023-03-01 22:58:22 +08:00
from django.contrib.auth import get_user_model
User = get_user_model()
2023-02-24 00:13:44 +08:00
# Create your models here.
class Note(models.Model):
title = models.CharField(max_length=20)
2023-03-03 23:47:30 +08:00
content = models.TextField()
2023-02-24 00:13:44 +08:00
date_created = models.DateTimeField(default=now, editable=False)
2023-03-01 22:58:22 +08:00
owner = models.ForeignKey(User, on_delete=models.CASCADE)
2023-02-24 00:13:44 +08:00
def __str__(self):
return self.title