Comment Detail

입력한 pk와 일치하는 Comment Object에 대한 정보를 반환합니다.

Comment Object에 딸려있는 모든 Sub Comment 혹은 바로 밑에 있는 Sub Comment들을 Filtering 을 통해 뽑아 올 수 있습니다.

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

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

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

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

URL

/post/comment/<pk>/

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

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

Filter Query Parameters

Parameter Description Type uri
immediate_children Comment의 immediate_children(바로 밑의 자식들) Boolean /post/comment/<pk>?immediate_children=True
all_children Comment의 all_children(모든 자식들) Boolean /post/comment/<pk>?all_children=True
ordering ordering by value - value로 전달된 created_at 혹은 modified_at을 통해 순서를 재배열, 앞에 - 를 붙여 순서를 reverse Str /post/answer/?ordering=created_at 오래된 순 /post/answer/?ordering=-created_at
page page - 전체 result에서 몇번째 페이지에 해당하는 result를 가지고 올지 요청 Int /post/answer/?page=2

Method

GET


Success Response

HTTP Status Code

200

Content

/post/comment/<pk>/?all_children=True

Key Description Type
pk Answer의 pk Int
user User의 pk Int
related_post Comment가 달린 Post의 종류와 pk Str
parent Comment 가 만약 최상위 Comment가 아니면 있을 위 parent의 pk Int
content Comment의 내용 Str
created_at 생성된 날짜 Int
modified_at 마지막으로 수정된 날짜 - 처음 생성되었을 때는 created_at과 같음 Int
all_children_count 모든 자식 Comment의 개수 Int
results 해당 Comment의 Sub Comment - Query parameter에 따라 all_children이 될 수도, immediate_children이 될 수도 있다. List
{
    "pk": 7,
    "user": 1,
    "related_post": "question - 2",
    "parent": null,
    "content": "코멘트입니다.",
    "created_at": "2017-12-06T20:13:57.939801+09:00",
    "modified_at": "2017-12-06T22:19:54.853668+09:00",
    "all_children_count": 9,
    "results": [
        {
            "pk": 12,
            "user": 1,
            "related_post": "question - 6",
            "parent": 7,
            "content": "Nested Comment Depth 1",
            "created_at": "2017-12-07T01:30:16.719276+09:00",
            "modified_at": "2017-12-07T01:30:16.719303+09:00",
            "all_children_count": 7
        },
        {
            "pk": 14,
            "user": 1,
            "related_post": "question - 6",
            "parent": 12,
            "content": "Nested Comment1 Depth 2",
            "created_at": "2017-12-07T01:30:33.448527+09:00",
            "modified_at": "2017-12-07T01:30:33.448553+09:00",
            "all_children_count": 0
        },
        {
            "pk": 15,
            "user": 1,
            "related_post": "question - 6",
            "parent": 12,
            "content": "Nested Comment2 Depth 2",
            "created_at": "2017-12-07T01:30:37.669742+09:00",
            "modified_at": "2017-12-07T01:30:37.669769+09:00",
            "all_children_count": 0
        },
        {
            "pk": 16,
            "user": 1,
            "related_post": "question - 6",
            "parent": 12,
            "content": "Nested Comment3 Depth 2",
            "created_at": "2017-12-07T01:30:45.965446+09:00",
            "modified_at": "2017-12-07T01:30:45.965468+09:00",
            "all_children_count": 0
        },
        {
            "pk": 17,
            "user": 1,
            "related_post": "question - 6",
            "parent": 12,
            "content": "Nested Comment4 Depth 2",
            "created_at": "2017-12-07T01:30:48.953074+09:00",
            "modified_at": "2017-12-07T01:30:48.953099+09:00",
            "all_children_count": 0
        }
    ],
    "next": "http://localhost:8000/post/comment/7/?all_children=True&page=2",
    "previous": null
}

/post/comment/<pk>/?immediate_children=True

all_children의 모든 항목을 갖고 있으며, result의 결과(바로 밑 자식 Comment들)의 개수를 나타내는 immediate_children_count 필드가 추가됩니다.

Key Description Type
immediate_children_count 바로 밑 자식 Comment들의 개 Int
{
    "pk": 7,
    "user": 1,
    "related_post": "question - 2",
    "parent": null,
    "content": "코멘트입니다.",
    "created_at": "2017-12-06T20:13:57.939801+09:00",
    "modified_at": "2017-12-06T22:19:54.853668+09:00",
    "all_children_count": 9,
    "immediate_cihldren_count": 2,
    "results": [
        {
            "pk": 12,
            "user": 1,
            "related_post": "question - 6",
            "parent": 7,
            "content": "Nested Comment Depth 1",
            "created_at": "2017-12-07T01:30:16.719276+09:00",
            "modified_at": "2017-12-07T01:30:16.719303+09:00",
            "all_children_count": 7
        },
        {
            "pk": 13,
            "user": 1,
            "related_post": "question - 6",
            "parent": 7,
            "content": "Nested Comment2 Depth 1",
            "created_at": "2017-12-07T01:30:26.687611+09:00",
            "modified_at": "2017-12-07T01:30:26.687636+09:00",
            "all_children_count": 0
        }
    ],
    "next": null,
    "previous": null
}

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"
}

results matching ""

    No results matching ""