Commit e2b352df authored by Trisha Angel Millena's avatar Trisha Angel Millena

edited admin.py and models.py

parent b233dbd9
...@@ -3,13 +3,17 @@ from .models import ForumPost, Reply ...@@ -3,13 +3,17 @@ from .models import ForumPost, Reply
# Register your models here. # Register your models here.
class ReplyInLine(admin.TabularInLine):
model = Reply
class ForumPostAdmin(admin.ModelAdmin): class ForumPostAdmin(admin.ModelAdmin):
model = ForumPost model = ForumPost
list_display = ('title', 'body', 'pub_datetime') list_display = ('title', 'body', 'pub_datetime')
inlines = [ReplyInLine]
class ReplyAdmin(admin.ModelAdmin): class ReplyAdmin(admin.ModelAdmin):
model = Reply model = Reply
list_display = ('body', 'pub_datetime') list_display = ('body', 'pub_datetime')
admin.site.register(ForumPost, ForumPostAdmin) admin.site.register(ForumPost, ForumPostAdmin)
admin.site.register(Reply, ReplyAdmin) admin.site.register(Reply, ReplyAdmin)
\ No newline at end of file
...@@ -9,8 +9,14 @@ class ForumPost(models.Model): ...@@ -9,8 +9,14 @@ class ForumPost(models.Model):
author = models.ForeignKey(WidgetUser, on_delete = models.CASCADE) author = models.ForeignKey(WidgetUser, on_delete = models.CASCADE)
pub_datetime = models.DateTimeField() pub_datetime = models.DateTimeField()
def _str_(self):
return self.title
class Reply(models.Model): class Reply(models.Model):
body = models.CharField(max_length = 300) body = models.CharField(max_length = 300)
author = models.ForeignKey(WidgetUser, on_delete = models.CASCADE) author = models.ForeignKey(WidgetUser, on_delete = models.CASCADE)
pub_datetime = models.DateTimeField() pub_datetime = models.DateTimeField()
post = models.ForeignKey(ForumPost, on_delete = models.CASCADE) post = models.ForeignKey(ForumPost, on_delete = models.CASCADE)
def _str_(self):
return self.author
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