Commit 1fc0333b authored by Joshua de Vera's avatar Joshua de Vera

Updated admin.py & models.py

Edited the two files to better incorporate with the main branch's version
parent 39cfee87
from django.contrib import admin
from .models import Announcement
#from .models import WidgetUser, Announcement, Post, Assignment
\ No newline at end of file
class AnnouncementAdmin(admin.ModelAdmin):
model = Announcement
search_fields = ('announcement_title', 'announcement_body', 'pub_date')
list_display = ('announcement_title', 'announcement_body', 'pub_date')
list_filter = ('announcement_title', 'announcement_body', 'pub_date')
fieldsets = [
('Announcement Data', {
'fields': [
'announcement_title',
'announcement_body',
'pub_date'
]
})
]
#Register models
admin.site.register(Announcement, AnnouncementAdmin)
\ No newline at end of file
from django.db import models
from django.urls import reverse
class Announcement(models.Model):
class AnnouncementAdmin(models.Model):
announcement_title= models.CharField(max_length=50)
announcement_body = models.CharField(max_length=200)
pub_date = models.DateTimeField(auto_now_add=True)
def __str__(self):
return self.announcement_title
\ No newline at end of file
return self.full_announcement
def get_absolute_url(self):
return reverse('Announcement', args=[(self.full_name)])
@property
def full_announcement(self):
return '{} {} {}'.format(self.announcement_title, self.announcement_body, self.pub_date)
\ 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