Django Section 9

yoodeit·2025년 8월 23일

일단 만드는 어무해

목록 보기
18/21

Article이 project에 속하도록

1) articleapp/models.py 변경

2) articleapp/forms.py 변경

3) migrate 해주기

중간에 변경되더라도 똑같이 migrate를 해주면 됩니다.

그럼 이런식으로 project를 고를 수가 있게 됨.

프로필에서 pin한 프로젝트가 보이도록

1) projectapp/views.py 수정(mixin 사용때문)

mixin을 import 해줍니다.
from django.views.generic.list import MultipleObjectMixin

2) articleapp/list.html 복사

3) projectapp/snippets/list_fragment.html 로 옮기기

복붙인데 약간의 수정이 필요함.
base.html을 extend하는 부분이나, block content 같은 것들은 싸그리 없애야 함.

4) detail.html에 list_fragment include하기

원하는 부분에

<div>
        {% include 'projectapp/snippets/list_fragment.html' with article_list=object_list %}

    </div>

이 구문을 추가하기

mypage에서도 쓴 글이 보이도록

1) accountapp/views.py 수정.

2) accountapp/detail.html

수정하는 건 방식은 똑같음. 끝 !

profile
Yoodeit

0개의 댓글