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