Commit 11b9e63d authored by Eldon Dagdag's avatar Eldon Dagdag

Populated models and added Inline Admin Panel

parent 65381896
from django.contrib import admin from django.contrib import admin
from .models import ForumPost, Reply from .models import Reply, ForumPost
class ReplyInline(admin.TabularInline):
model = Reply
class ForumPostAdmin(admin.ModelAdmin): class ForumPostAdmin(admin.ModelAdmin):
model = ForumPost model = ForumPost
search_fields = ('title', 'author',)
class ReplyAdmin(admin.ModelAdmin): list_display = ('title', 'author',)
model = Reply list_filter = ('title', 'author',)
inlines = [ReplyInline]
# Register your models here. # Register your models here.
admin.site.register(ForumPost, ForumPostAdmin) admin.site.register(Reply)
admin.site.register(Reply, ReplyAdmin) admin.site.register(ForumPost, ForumPostAdmin)
\ No newline at end of file \ No newline at end of file
...@@ -9,7 +9,7 @@ def index(request): ...@@ -9,7 +9,7 @@ def index(request):
for post in ForumPost.objects.all(): for post in ForumPost.objects.all():
post_string = '{} by {} {} posted {}:<br>'.format( post_string = '{} by {} {} posted {}:<br>'.format(
post.title, post.author.first_name, post.author.last_name, post.title, post.author.first_name, post.author.last_name,
post.pub_datetime.strftime("%m/%d/%Y %I:%M %p") post.pub_datetime.strftime("%m/%d/%Y, %I:%M %p")
) )
post_string += '{}<br>'.format(post.body) post_string += '{}<br>'.format(post.body)
return_string += post_string return_string += post_string
...@@ -18,7 +18,7 @@ def index(request): ...@@ -18,7 +18,7 @@ def index(request):
if post == reply.reply_to: if post == reply.reply_to:
reply_string = 'Reply by {} {} posted {}:<br>'.format( reply_string = 'Reply by {} {} posted {}:<br>'.format(
reply.author.first_name, reply.author.last_name, reply.author.first_name, reply.author.last_name,
reply.pub_datetime.strftime("%m/%d/%Y %I:%M %p") reply.pub_datetime.strftime("%m/%d/%Y, %I:%M %p")
) )
reply_string += '{}<br>'.format(reply.body) reply_string += '{}<br>'.format(reply.body)
return_string += reply_string return_string += reply_string
......
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