Question List

Question의 리스트를 리턴합니다.

query parameters로 필터링을 지원합니다.

paramter 간의 &연산이 가능합니다. ex) /post/question/?user=1&ordering=created_at

Pagination query parameter의 key값으로 page를 전달하여 원하는 페이지에 접근이 가능합니다. 한 페이지당 5개의 objects가 리턴됩니다.

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

최대 페이지 이후의 값은 최대 페이지와 동일한 objects들을 리턴합니다.

URL

/post/question/

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

Method

GET

Query Parameters

Parameter Description Type URI
user 유저의 모든 질문 Integer /post/question/?user=1
followed_by 유저가 팔로우하는 질문 Integer /post/question/?followed_by=1
bookmared_by 유저가 북마크하는 질문 Integer /post/question/?bookmarked_by=1
answered_by 유저가 답변한 질문 Integer /post/question/?answered_by=1
topic 해당 topic을 포함하는 질문 Integer /post/question/?topic=1
ordering 질문 정렬 순서(앞에 -가 붙으면 역순) String /post/question/?ordering=created_at /post/question/?ordering=-created_at /post/question/?ordering=modified_at /post/question/?ordering=-modified_at
page 몇번째 페이지에 해당하는 지에 대한 페이지 값 Integer /post/question/?page=1

Seccess Response

HTTP Status Code

200

Key Description Type
count objects의 갯수 Integer
next 다음 페이지 URI Integer
previous 이전 페이지 URI Integer
pk Question pk Integer
url pk에 해당하는 질문의 question-detail 페이지 링크 String
user 질문을 생성한 유저의 profile-main-detail 페이지 링크 String
content 질문 내용 String
bookmark_count 해당 질문을 북마크 한 수 Integer
follow_count 해당 질문을 팔로우 한 수 Integer
comment_count 해당 질문에 달린 댓글 수 Integer
created_at 질문 생성 날짜 Date
modified_at 질문 수정 날짜 Date
topics 해당 질문이 속하는 토픽들의 topic-detail 링크 String

/post/question/?bookmarked_by=1&ordering=-created_at

{
    "count": 10,
    "next": "http://localhost:8000/post/question/?page=2",
    "previous": null,
    "results": [
        {
            "question": {
                "pk": 3,
                "url": "http://localhost:8000/post/question/3/",
                "user": "http://localhost:8000/user/1/profile/main-detail/",
                "content": "대통령 선거날짜가 언제인가요?",
                "bookmark_count": 1,
                "follow_count": 0,
                "comment_count": 3,
                "created_at": "2017-12-13",
                "modified_at": "2017-12-13T08:57:41.774859+09:00"
            },
            "topics": [
                "http://localhost:8000/topic/1/",
                "http://localhost:8000/topic/2/"
            ]
        },
        {
            "question": {
                "pk": 5,
                "url": "http://localhost:8000/post/question/5/",
                "user": "http://localhost:8000/user/1/profile/main-detail/",
                "content": "대통령 선거날짜가 언제인가요?",
                "bookmark_count": 0,
                "follow_count": 0,
                "comment_count": 0,
                "created_at": "2017-12-13",
                "modified_at": "2017-12-13T08:58:56.420174+09:00"
            },
            "topics": [
                "http://localhost:8000/topic/3/"
            ]
        }
    ]
}

Error Response

Bad Request Error

HTTP Status Code

400

Content

value 값이 없을 때

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

Bad Request Error

HTTP Status Code

400

Content

parameter값이 잘못됐을 때

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

results matching ""

    No results matching ""