4041 Django get_object_or_404! # main.html 상세보기 # urls.py path('post/', post.views.detail, name="detail") # views.py def detail(request, post_id): post_detail = get_object_or_404(Post, pk=post_id) return render(request, 'post/detail.html', {'post':post_detail}) 1. main.html : main에서 상세페이지로 넘어갈 때 post.id를 같이 넘겨준다. 2. path-converter : post가 생성될 때마다 post_id를 path-converter로 하여 detail함수에 넘겨준다는 의미이다. 3. get_object_or_404 : path-co.. 2022. 6. 13. 이전 1 다음