Edited and migrated models

parent 7dbe8ebb
# Generated by Django 3.2 on 2023-05-12 08:38
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('forum', '0002_alter_forumpost_author'),
]
operations = [
migrations.AlterModelOptions(
name='forumpost',
options={'ordering': ['pub_datetime']},
),
]
...@@ -12,9 +12,15 @@ class ForumPost(models.Model): ...@@ -12,9 +12,15 @@ class ForumPost(models.Model):
) )
pub_datetime = models.DateTimeField() pub_datetime = models.DateTimeField()
class Meta:
ordering = ['pub_datetime']
def __str__(self): def __str__(self):
return '{}'.format(self.title) return '{}'.format(self.title)
def get_absolute_url(self):
return reverse("forum:forumpostdetails", kwargs={"pk": self.pk})
class Reply(models.Model): class Reply(models.Model):
body = models.TextField() body = models.TextField()
author = models.CharField(max_length=50) author = models.CharField(max_length=50)
...@@ -23,4 +29,5 @@ class Reply(models.Model): ...@@ -23,4 +29,5 @@ class Reply(models.Model):
ForumPost, ForumPost,
on_delete=models.CASCADE on_delete=models.CASCADE
) )
def get_absolute_url(self):
\ No newline at end of file return reverse("forum:replydetails", kwargs={'pk': self.pk})
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment