Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jean Michel Rouly
research-questions
Commits
5764f646
Commit
5764f646
authored
Dec 04, 2013
by
Jean Michel Rouly
Browse files
Added children accessors.
parent
b7f1ef70
Changes
1
Hide whitespace changes
Inline
Side-by-side
researchquestions/website/models.py
View file @
5764f646
...
...
@@ -10,6 +10,10 @@ class Question( models.Model ):
text
=
models
.
TextField
(
max_length
=
1000
)
rating
=
models
.
IntegerField
(
default
=
0
)
def
get_comments
(
self
):
comments
=
Comment
.
objects
.
filter
(
parent__pk
=
self
.
pk
)
return
comments
def
__unicode__
(
self
):
return
'%s, %s'
%
(
self
.
user
,
self
.
date
)
...
...
@@ -19,6 +23,10 @@ class Comment( models.Model ):
text
=
models
.
TextField
()
parent
=
models
.
ForeignKey
(
'Question'
)
def
get_replies
(
self
):
replies
=
Reply
.
objects
.
filter
(
parent__pk
=
self
.
pk
)
return
replies
def
__unicode__
(
self
):
return
'%s, %s'
%
(
self
.
user
,
self
.
date
)
...
...
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