Django-NotesApp/project/notes/models.py

16 lines
481 B
Python
Raw 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)
content = models.CharField(max_length=1024)
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