Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
widgets_FEKK
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kyla Martin
widgets_FEKK
Commits
94a82378
Commit
94a82378
authored
Mar 26, 2022
by
Emmanuel Linus T. Evangelista
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add print method and admin config for Reply and Post models
parent
9604e650
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
3 deletions
+24
-3
admin.py
WidgetFEKK/Forum/admin.py
+14
-2
models.py
WidgetFEKK/Forum/models.py
+10
-1
No files found.
WidgetFEKK/Forum/admin.py
View file @
94a82378
...
...
@@ -3,5 +3,17 @@ from django.contrib import admin
# Register your models here.
from
.models
import
Post
,
Reply
admin
.
site
.
register
(
Post
)
admin
.
site
.
register
(
Reply
)
\ No newline at end of file
class
PostAdmin
(
admin
.
ModelAdmin
):
model
=
Post
search_fields
=
[
'post_title'
,
'post_body'
,
'author'
]
list_display
=
[
'post_title'
,
'post_body'
,
'pub_date'
,
'author'
]
list_filter
=
[
'author'
]
class
ReplyAdmin
(
admin
.
ModelAdmin
):
model
=
Reply
search_fields
=
[
'reply_body'
,
'author'
,
'post'
]
list_display
=
[
'post'
,
'reply_body'
,
'pub_date'
,
'author'
]
list_filter
=
[
'author'
]
admin
.
site
.
register
(
Post
,
PostAdmin
)
admin
.
site
.
register
(
Reply
,
ReplyAdmin
)
\ No newline at end of file
WidgetFEKK/Forum/models.py
View file @
94a82378
...
...
@@ -9,9 +9,18 @@ class Post(models.Model):
author
=
models
.
ForeignKey
(
WidgetUser
,
on_delete
=
models
.
CASCADE
,
default
=
1
)
def
__str__
(
self
):
return
self
.
post_title
class
Reply
(
models
.
Model
):
reply_body
=
models
.
CharField
(
max_length
=
500
)
pub_date
=
models
.
DateTimeField
(
"date published"
,
auto_now_add
=
True
)
author
=
models
.
ForeignKey
(
WidgetUser
,
on_delete
=
models
.
CASCADE
,
default
=
1
)
post
=
models
.
ForeignKey
(
Post
,
on_delete
=
models
.
CASCADE
)
\ No newline at end of file
post
=
models
.
ForeignKey
(
Post
,
on_delete
=
models
.
CASCADE
)
def
__str__
(
self
):
if
len
(
self
.
reply_body
)
>
30
:
return
self
.
reply_body
[
0
:
30
]
+
'...'
else
:
return
self
.
reply_body
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment