지금 게시물을 작성하고 게시 버튼을 누르면, 작성하기 페이지가 다시한번 로드됩니다. 실제로 작성은 되었지만, 즉각적으로 확인하기 어려운 상태입니다.
일반적으로는 게시글을 작성하면 그 게시물의 자세히보기 페이지로 이동시키는 코드를 심어줍니다.
아래 코드에서 1번째 줄과 2번째 줄을 살펴봅시다.
views.pyfrom django.shortcuts import render, redirect# 중간생략def new_feed(request):if request.method == 'POST': # 폼이 전송되었을 때만 아래 코드를 실행new_article = Article.objects.create(author=request.POST['author'],title=request.POST['title'],text=request.POST['content'],password=request.POST['password'])# 새글 등록 끝return redirect(f'/feed/{ new_article.pk }')return render(request, 'new_feed.html')