{ comment }

  • 장고 Comment 기능 학습

    |

    Comment 기능 구현

    Comment 기능 적용 방법 중, 현재까지 공부한 방법으로는 크게 2가지로 나뉠 수 있다.

    • 특정 앱에 comment 모델 생성하여 구현하는 방법
    • comment 앱 추가 생성하여 구현하는 방법
    • 여기서는 블로그 프로젝트를 예로 들어, comment 앱을 추가 생성하여 댓글 기능 구현 방법을 정리해보았다.
  • 장고 - Ajax 이용한 댓글 기능 구현

    |

    댓글 생성하기

    1. 상세 글 조회 페이지에 댓글 목록 추가

    • 원하는 위치에 댓글 목록 부분을 작성한다.
    • 경로 : board > templates > board > document_detail.html
      1
      2
      3
      <div id="docs_comment_list_area">
      {% include 'board/comment_list.html' %}
      </div>
  • 장고 - 게시판 댓글 기능 적용

    |

    ex) 게시판 프로젝트(board_project)

    1. 특정 페이지에서 댓글 템플릿 연동

    • 댓글 목록의 template 따로 생성 (댓글 부분 페이지네이션 필요하기 때문)
    • 경로 : templates > board > comment_list.html
      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      <table class="table table-striped">
      <thead>
      <tr>
      <th colspan="3" class="align-left">댓글 목록</th>
      </tr>
      </thead>
      {% for comment in comments %}
      <tr>
      <td>{{comment.text}}</td>
      <td>{{comment.author.username}}</td>
      <td>{{comment.created}}</td>
      </tr>
      {% endfor %}
      </table>
  • 장고 - disqus 연동한 댓글 기능 적용

    |

    1. disqus.com 접속

    • 회원가입 및 로그인
    • ‘I want to install isqus in my site’ 클릭
    • Basic > ‘subscribe now’ 클릭
    • 플랫폼 선택(보이지 않는다면, ‘I don’t see~’ 클릭)
    • 최하단 ‘Configure’ 클릭
    • 변경할 것이 특별히 없다면 최하단 ‘Complete Setup’ 클릭