]>
git.p6c8.net - pcdenotes.git/blob - notes/models.py
1 from django
.db
import models
2 from django
.contrib
.auth
.models
import User
3 from django
.urls
import reverse
5 # Create your models here.
7 NOTE_STATUS
= ((0, "Draft"),
10 class Note(models
.Model
):
11 title
= models
.CharField(max_length
=250)
12 slug
= models
.SlugField(max_length
=250, unique
=True)
13 author
= models
.ForeignKey(User
, on_delete
=models
.CASCADE
, related_name
='notes_posted')
14 content
= models
.TextField()
15 status
= models
.IntegerField(choices
=NOTE_STATUS
, default
=0)
17 created_at
= models
.DateTimeField(auto_now_add
=True)
18 updated_at
= models
.DateTimeField(auto_now
=True)
21 ordering
= ['-created_at']
26 def get_absolute_url(self
):
27 return reverse("notes:note_detail", kwargs
={"note_slug": self
.slug
})
28 #return "/notes/%s" % (self.slug)
patrick-canterino.de