Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
midterm_k3git
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
Stefan Gomez
midterm_k3git
Commits
9dd377bb
Commit
9dd377bb
authored
May 14, 2023
by
Migs Atienza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added forumpost-details.html (but error in pks)
parent
069c0f7f
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
36 additions
and
3 deletions
+36
-3
db.sqlite3
widget_k3git/db.sqlite3
+0
-0
models.cpython-39.pyc
widget_k3git/forum/__pycache__/models.cpython-39.pyc
+0
-0
urls.cpython-39.pyc
widget_k3git/forum/__pycache__/urls.cpython-39.pyc
+0
-0
views.cpython-39.pyc
widget_k3git/forum/__pycache__/views.cpython-39.pyc
+0
-0
models.py
widget_k3git/forum/models.py
+4
-1
forum.html
widget_k3git/forum/templates/forum/forum.html
+1
-1
forumpost-details.html
widget_k3git/forum/templates/forum/forumpost-details.html
+20
-0
urls.py
widget_k3git/forum/urls.py
+2
-1
views.py
widget_k3git/forum/views.py
+9
-0
No files found.
widget_k3git/db.sqlite3
View file @
9dd377bb
No preview for this file type
widget_k3git/forum/__pycache__/models.cpython-39.pyc
View file @
9dd377bb
No preview for this file type
widget_k3git/forum/__pycache__/urls.cpython-39.pyc
View file @
9dd377bb
No preview for this file type
widget_k3git/forum/__pycache__/views.cpython-39.pyc
View file @
9dd377bb
No preview for this file type
widget_k3git/forum/models.py
View file @
9dd377bb
from
django.db
import
models
from
django.urls
import
reverse
class
ForumPost
(
models
.
Model
):
title
=
models
.
CharField
(
max_length
=
100
)
...
...
@@ -10,6 +10,9 @@ class ForumPost(models.Model):
def
__str__
(
self
):
return
'{} by {}'
.
format
(
self
.
title
,
self
.
author
)
def
get_absolute_url
(
self
):
return
reverse
(
'forum:forumpost-details'
,
kwargs
=
{
'pk'
:
self
.
pk
})
class
Reply
(
models
.
Model
):
body
=
models
.
TextField
(
max_length
=
1000
)
...
...
widget_k3git/forum/templates/forum/forum.html
View file @
9dd377bb
...
...
@@ -5,7 +5,7 @@
<h1>
Welcome to Widget's Forum!
</h1>
<h3>
{% for post in forumposts %}
<a
href=
"{{
forum
.get_absolute_url }}"
>
{{ post.title }} by {{ post.author }}
</a><br>
<a
href=
"{{
post
.get_absolute_url }}"
>
{{ post.title }} by {{ post.author }}
</a><br>
{% endfor %}
</h3>
{% endblock %}
...
...
widget_k3git/forum/templates/forum/forumpost-details.html
0 → 100644
View file @
9dd377bb
{% extends 'base.html' %}
{% block title %}{{ reply.forum_post.title }}{% endblock %}
{% block content %}
<h1>
{{ reply.forum_post.title }}
</h1>
<h3>
by {{ reply.forum_post.author }}
<br>
{{ reply.forum_post.pub_datetime }}
<br>
{{ reply.forum_post.body }}
<br>
</h3>
<br>
<h1>
POST REPLIES
</h1>
<h3>
by {{ reply.author }}
{{ reply.pub_datetime }}
{{ reply.body }}
</h3>
{% endblock %}
{% block scripts %}
<a
href=
"/forum/forumposts{{ reply.forum_post.pk }}/edit"
><input
type=
"submit"
value=
"Edit Post"
></a>
{% endblock %}
\ No newline at end of file
widget_k3git/forum/urls.py
View file @
9dd377bb
from
django.contrib
import
admin
from
django.urls
import
path
from
.views
import
index
from
.views
import
index
,
ForumPostDetailView
urlpatterns
=
[
path
(
''
,
index
,
name
=
'index'
),
path
(
'forumposts/<int:pk>/details'
,
ForumPostDetailView
.
as_view
(),
name
=
'forumpost-details'
),
]
app_name
=
"forum"
\ No newline at end of file
widget_k3git/forum/views.py
View file @
9dd377bb
from
django.shortcuts
import
render
from
django.http
import
HttpResponse
from
django.views.generic.detail
import
DetailView
from
django.views.generic.edit
import
CreateView
,
UpdateView
from
.models
import
ForumPost
,
Reply
...
...
@@ -7,4 +9,11 @@ from .models import ForumPost, Reply
def
index
(
request
):
return
render
(
request
,
'forum/forum.html'
,
{
'forumposts'
:
ForumPost
.
objects
.
all
()})
class
ForumPostDetailView
(
DetailView
):
model
=
Reply
def
get
(
self
,
request
,
pk
):
return
render
(
request
,
'forum/forumpost-details.html'
,
{
'reply'
:
self
.
model
.
objects
.
get
(
pk
=
pk
)})
# Create your views here.
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