Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
midterm_casanatics
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
John Aidan Vincent M. Ng
midterm_casanatics
Commits
a4affa42
Commit
a4affa42
authored
Mar 04, 2023
by
justin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed admin.py and models.py formatting
parent
030df003
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
17 deletions
+13
-17
admin.py
widget_casanatics/forum/admin.py
+6
-5
models.py
widget_casanatics/forum/models.py
+7
-12
No files found.
widget_casanatics/forum/admin.py
View file @
a4affa42
from
django.contrib
import
admin
from
django.contrib
import
admin
# Register your models here.
from
.models
import
ForumPost
,
Reply
from
.models
import
ForumPost
,
Reply
class
ForumPostAdmin
(
admin
.
ModelAdmin
):
class
ForumPostAdmin
(
admin
.
ModelAdmin
):
model
=
ForumPost
model
=
ForumPost
list_display
=
(
'title'
,
'author'
,
'body'
,
'pub_datetime'
)
list_display
=
(
"title"
,
"author"
,
"body"
,
"pub_datetime"
)
class
ReplyAdmin
(
admin
.
ModelAdmin
):
class
ReplyAdmin
(
admin
.
ModelAdmin
):
model
=
Reply
model
=
Reply
list_display
=
(
'forum'
,
'author'
,
'body'
,
'pub_datetime'
)
list_display
=
(
"forum"
,
"author"
,
"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
widget_casanatics/forum/models.py
View file @
a4affa42
from
django.db
import
models
from
django.db
import
models
# if need to
import WidgetUser
from
dashboard.models
import
WidgetUser
# from widget_casanatics.dashboard.models import WidgetUser
# Create your models here.
class
ForumPost
(
models
.
Model
):
class
ForumPost
(
models
.
Model
):
title
=
models
.
CharField
(
max_length
=
50
)
title
=
models
.
CharField
(
max_length
=
50
)
body
=
models
.
CharField
(
max_length
=
1000
)
body
=
models
.
CharField
(
max_length
=
1000
)
author
=
models
.
CharField
(
max_length
=
100
)
author
=
models
.
ForeignKey
(
WidgetUser
,
on_delete
=
models
.
CASCADE
)
# If connecting to WidgetUser
pub_datetime
=
models
.
DateTimeField
(
"Published Date and Time"
,
auto_now_add
=
True
)
# author = models.ForeignKey(WidgetUser, on_delete = models.CASCADE)
pub_datetime
=
models
.
DateTimeField
(
"Published Date and Time"
)
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
title
return
self
.
title
class
Reply
(
models
.
Model
):
class
Reply
(
models
.
Model
):
forum
=
models
.
ForeignKey
(
ForumPost
,
on_delete
=
models
.
CASCADE
)
forum
=
models
.
ForeignKey
(
ForumPost
,
on_delete
=
models
.
CASCADE
)
body
=
models
.
CharField
(
max_length
=
1000
)
body
=
models
.
CharField
(
max_length
=
1000
)
author
=
models
.
CharField
(
max_length
=
100
)
author
=
models
.
ForeignKey
(
WidgetUser
,
on_delete
=
models
.
CASCADE
)
# If connecting to WidgetUser
pub_datetime
=
models
.
DateTimeField
(
"Published Date and Time"
,
auto_now_add
=
True
)
# author = models.ForeignKey(WidgetUser, on_delete = models.CASCADE)
pub_datetime
=
models
.
DateTimeField
(
"Published Date and Time"
)
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
body
return
self
.
body
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