본문 바로가기
개발일지/멀티캠퍼스 프로젝트형 AI 국비지원

2022.02.16 Day-21? django 오류 복기

by 개발에정착하고싶다 2022. 2. 16.
320x100

나는 분명 잘 따라했다고 생각했는데, 어쨌든 작동이 안되더라.

그래서 이걸 강사님 코드와 내꺼를 대조해보면서 봤더니 생각외로 정말 많이 틀렸더라.

 

게다가 눈으로만 훑어봤을때 3번정도 안걸러진게 있어서

에러가 나는 경로를 찾아서 따로 고쳐갔고,

결국 고쳐내었다.

 

음.. 그런데 이게 맞는 코드에 대해서 대조군이 있으면 그나마 수월하지만 차후에

현업에서 일하게 되었을 때는 이 에러들을 어떻게 해결하면 좋을까? 라는 생각이 들기도 했다.

구글링을 하면 된다지만 그다지 적절한 답변을 고르진 못하고 있는것 때문일까

아니면 내가 아예 코딩관련하여 구글링을 할줄 모르는 것인가

 

뭐 당연하겠지만 후자겠지?

 

아무튼 내가 틀렸던 것을 복기 하기 위해 올려본다.

 

2022.02.16
틀림노트

1. bbs app -> templates -> bbs -> create.html

맞는코드
{% block html_header %}

내 코드
{% block html_body %}


2. bbs app -> templates -> bbs -> list.html

맞는 코드
<button type="button"
            class="btn btn-primary"
            onclick="new_post()">새글 작성</button>

내 코드

<button type="button" class="btn-primary" onclick="new_post()">새글 작성</button>


3. 2. bbs app -> templates -> bbs -> list.html
# for 문을 안끊어줬다.
맞는 코드

</tr>
            {% endfor %}
        </tbody>
    </table>
</div>
{% endblock %}


내 코드

</tr>
        </tbody>
    </table>
</div>
{% endblock %}


4. bbs.templates - views.py 

맞는 코드
return render(request, 'bbs/list.html', context)

내 코드
return render(request, 'bbs/list.html', context)


5. static - js - menu_btn.js

맞는 코드
document.location.href = '/bbs/create/' # 왜 상위 폴더였던 templates는 작성이 안되어도 작동될까?

내 코드
document.location.href = 'http://www.naver.com'


6. templates - index.html

맞는 코드
<link href="/static/css/cover.css" rel="stylesheet">

내 코드
<link href="cover.css" rel="stylesheet">



7. templates - index.html

맞는 코드
<a href="/bbs/list/"
         class="btn btn-lg btn-secondary fw-bold border-white bg-white">Enter BBS!!</a>

내 코드
<a href="http://127.0.0.1:8000/bbs/list"
         class="btn btn-lg btn-secondary fw-bold border-white bg-white">Enter BBS!!</a>


8. templates - index.html 

그냥 내 코드에 추가로
<p>Cover template for <a href="https://getbootstrap.com/" class="text-white">Bootstrap</a>, by <a href="https://twitter.com/mdo" class="text-white">@mdo</a>.</p>


9. bbs.templates - bbs - list.html

맞는 코드
{% block html_header %}


틀린 코드
{% block html_body %}

300x250