Comment List

Comment Object 중 Parent가 null 인 comment들을 반환합니다.

Filtering: ...url/?<parameter>=<value> 에 parameter 과 value를 넣어 각종 필터링을 실행할 수 있습니다.

Ordering: 또한, 모든 포스트에 대해 ?ordering=modified_at, 혹은 ?ordering=-modified_at을 통해 오래된 순, 최신순 필터링을 실행할 수 있습니다.

Pagination: page를 통해 다음 페이지를 Access 할 수 있습니다. 한 페이지에는 5개의 post가 나옵니다.

next 를 통해 다음 5개의 post가 있는 페이지, previous 를 통해 이전 5개의 post가 있는 페이지를 부를 수 있습니다.

URL

/post/comment/

/post/comment/?<parameter>=<value>

Query Parameter를 붙일 시 url의 끝에 / 가 들어가지 않습니다. / 가 붙으면 internal server error 가 반환됩니다.

Filter Query Parameters

Parameter Description Type URI
answer Answer의 pk Int /post/comment/?answer=12
question Question 의 pk Int /post/comment/?question=21
ordering ordering by value - value 로 전달된 created_at 혹은 modified_at을 통해 순서를 재배열, 앞에 - 를 붙여 순서를 Reverse Str /post/comment/?ordering=created_at
page page - 전체 result 에서 몇번째 페이지에 해당하는 result를 갖고 올지를 결정 Int /post/comment/?page=4

Or / And 연산

Or 연산을 하고 싶을 때는 필드 뒤에 , 를 붙여 요청하면 됩니다. (예: /post/comment/?answer=1,2 = 유저 1 or 유저 2 or 유저 3이 쓴 Answer)

And 연산을 하고 싶을 때는 &를 추가하여 요청하면 됩니다. (예: /post/comment/?question=3&ordering=-created_at

Method

GET


Success Response

HTTP Status Code

200

Content

Key Description Type
count 총 hit 된 object의 개수 Int
next 다음 페이지로의 url Str
previous 이전 페이지로의 url Str
pk Comment의 pk Int
user 코멘트를 올린 유저의 pk Int
related_post Comment가 달린 Answer 혹은 Question의 정보를 String 포맷으로 변환 - "<post_type> - <post_pk>" 형식으로 표현 Str
parent Comment의 상위(존재하면) Comment의 pk Int
content Comment의 내용 Str
created_at Comment 생성된 날짜 Date
modified_at Comment가 마지막으로 수정된 날짜 Date
all_children_count Comment 밑에 있는 모든 하위 Comment의 개수 Int
{
    "count": 7,
    "next": "http://localhost:8000/post/comment/?ordering=-modified_at&page=2&question=6",
    "previous": null,
    "results": [
        {
            "pk": 21,
            "user": 1,
            "related_post": "question - 6",
            "parent": null,
            "content": "코멘트입니다.",
            "created_at": "2017-12-07T01:46:36.631455+09:00",
            "modified_at": "2017-12-07T01:46:36.631507+09:00",
            "upvote_count": 0,
            "downvote_count": 0,
            "all_children_count": 0
        },
        {
            "pk": 8,
            "user": 1,
            "related_post": "question - 6",
            "parent": null,
            "content": "코멘트입니다.",
            "created_at": "2017-12-06T20:23:04.110557+09:00",
            "modified_at": "2017-12-06T20:23:04.110588+09:00",
            "upvote_count": 0,
            "downvote_count": 0,
            "all_children_count": 0
        },
        {
            "pk": 6,
            "user": 1,
            "related_post": "question - 6",
            "parent": null,
            "content": "코멘트입니다.",
            "created_at": "2017-12-06T20:11:44.894597+09:00",
            "modified_at": "2017-12-06T20:11:44.894629+09:00",
            "upvote_count": 0,
            "downvote_count": 0,
            "all_children_count": 0
        },
        {
            "pk": 5,
            "user": 1,
            "related_post": "question - 6",
            "parent": null,
            "content": "코멘트입니다.",
            "created_at": "2017-12-06T20:11:28.369373+09:00",
            "modified_at": "2017-12-06T20:11:28.369401+09:00",
            "upvote_count": 0,
            "downvote_count": 0,
            "all_children_count": 0
        },
        {
            "pk": 4,
            "user": 1,
            "related_post": "question - 6",
            "parent": null,
            "content": "코멘트입니다.",
            "created_at": "2017-12-06T20:06:08.498827+09:00",
            "modified_at": "2017-12-06T20:06:08.498857+09:00",
            "upvote_count": 0,
            "downvote_count": 0,
            "all_children_count": 0
        }
    ]
}

Error Response

Bad Request Error

HTTP Status Code

400

Content

# query parameter를 보냈는데 value를 보내지 않았을 때 

{
    "message": "query parameter가 존재하나 value가 존재하지 않습니다."
}

Bad Request Error

HTTP Status Code

400

Content

# 잘못된 query parameter로 요청을 보냈을 때

{
    "message": "존재하지 않는 query_parameter입니다. 필터가 가능한 query_parameter는 다음과 같습니다: "
                "ordering', 'page', 'answer', 'qusetion'"
}

results matching ""

    No results matching ""