We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2ec3a15 commit a23025bCopy full SHA for a23025b
Models.py
@@ -0,0 +1,18 @@
1
+from django.conf import settings
2
+from django.db import models
3
+from django.utils import timezone
4
+
5
6
+class Post(models.Model):
7
+ author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
8
+ title = models.CharField(max_length=200)
9
+ text = models.TextField()
10
+ created_date = models.DateTimeField(default=timezone.now)
11
+ published_date = models.DateTimeField(blank=True, null=True)
12
13
+ def publish(self):
14
+ self.published_date = timezone.now()
15
+ self.save()
16
17
+ def __str__(self):
18
+ return self.title
0 commit comments