From 457f37e23c014103271d4563d17349e732039dc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=9E=AC=EC=98=81?= Date: Sat, 10 Aug 2019 03:21:17 +0900 Subject: [PATCH] =?UTF-8?q?file=20delete=20error=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- board/templates/board.html | 2 +- board/templates/board_new.html | 5 ++++- board/views.py | 24 +++++++++++++++--------- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/board/templates/board.html b/board/templates/board.html index 1351049..4f63232 100644 --- a/board/templates/board.html +++ b/board/templates/board.html @@ -52,7 +52,7 @@

GaSiRi Let's get it! man~

{% else %} {% endif %} - +
diff --git a/board/templates/board_new.html b/board/templates/board_new.html index a11294d..0c719f6 100644 --- a/board/templates/board_new.html +++ b/board/templates/board_new.html @@ -14,7 +14,10 @@

게시물 등록

+ {% if error %} + + {% endif %}
{% csrf_token %}
@@ -129,7 +132,7 @@

게시물 등록

break; case 6 : $("#file5").remove(); - count--; + count = count - 2; break; default : break diff --git a/board/views.py b/board/views.py index faaa348..451459b 100644 --- a/board/views.py +++ b/board/views.py @@ -17,13 +17,20 @@ def board_new(request) : def create(request) : ''' - for key in request.POST: - if len(request.POST[key]) == 0: + for key in request.POST: + print("----") + print(request.POST[key]) + if len(request.POST[key]) == 0 or request.POST[key] is None : return render(request, 'board_new.html', {'error': '빈칸이 있습니다.'}) ''' - if request.method == 'POST': boards = Board() + + if request.user.id is None : + return render(request, 'accounts/login.html', {'error': '게시물 작성을 위해 로그인해주세요.'}) + else : + boards.userId = request.user.id + boards.title = request.POST['title'] boards.order_price = request.POST['order_price'] boards.body = request.POST['body'] @@ -62,14 +69,14 @@ def create(request) : count = count + 1 - if request.user.username is None : - print("로그인 안됨") - - + + # 보완 - 로그인 상태 아닐 경우, #if(request.user.username is None) - boards.userId = request.user.id + + print(request.user.id ) + #boards.userId = request.user.id ## 수정필요 ## boards.save() @@ -100,7 +107,6 @@ def createcomment(request, board_id): comments.text = request.POST['text'] comments.price = request.POST['price'] comments.post = board_id - comments.save() return redirect('test', board_id)