Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UPDATE] author save issue #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added blog/__pycache__/__init__.cpython-37.pyc
Binary file not shown.
Binary file added blog/__pycache__/admin.cpython-37.pyc
Binary file not shown.
Binary file added blog/__pycache__/models.cpython-37.pyc
Binary file not shown.
Binary file added blog/__pycache__/urls.cpython-37.pyc
Binary file not shown.
Binary file added blog/__pycache__/views.cpython-37.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added blog/migrations/__pycache__/__init__.cpython-37.pyc
Binary file not shown.
31 changes: 20 additions & 11 deletions blog/templates/base.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
<header>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css"
integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
</header>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=, initial-scale=1.0">
<title>Document</title>
</head>

<body>
<div class="container">
{% block content %}
{% endblock %}
<hr>
</div>
</body>
<header>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css"
integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
</header>

<body>
<div class="container">
{% block content %}
{% endblock %}
<hr>
</div>
</body>
</html>
6 changes: 4 additions & 2 deletions blog/templates/detail.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'base.html '%}
{% extends 'base.html' %}


{% block content %}
Expand All @@ -8,9 +8,11 @@ <h1> {{blog.title}} </h1>

<br><br>
<form method="POST">
{% csrf_token %}
<!-- csrf token을 넣어주어야 csrf공격을 막을 수 있어요! POST 메소드를 사용 할 때에는 꼭 넣어주셔야 합니다. -->
<input type="button" value="HOME" onClick="location.href='http://127.0.0.1:8000/'">
<!-- HTML input type="button"으로 버튼에 링크걸기! -->

<!-- <a href="{%url 'home'%}"><input type="submit" value="HOME"></a>
버튼 안에 링크를 걸기 위해서는 위의 코드를 이용해야한다 -->
<a href="{%url 'edit' blog.id %}">EDIT</a>
Expand Down
3 changes: 2 additions & 1 deletion blog/templates/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ <h4>제목: </h4>
<br>

<h4>작성자: </h4>
<input type="text" name="title" value="{{blog.author}}">
<!-- input 값에 name을 바꾸지 않았꾼요! -->
<input type="text" name="author" value="{{blog.author}}">
<br>

<h4>본문: </h4>
Expand Down
2 changes: 1 addition & 1 deletion blog/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<tr>
<th scope="col">#</th>
<th scope="col">Title</th>
<th scope="col" style="width:20%"">Date</th>
<th scope="col" style="width:20%">Date</th>
<th scope=" col">Author</th>
</tr>
</thead>
Expand Down
2 changes: 2 additions & 0 deletions blog/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def create(request):
blog = Blog() #객체 틀 하나 가져오기
blog.title = request.GET['title'] #내용채우기
blog.body = request.GET['body']
blog.author = request.GET['author'] # 작성자를 받아오지 않네요!
blog.pub_date = timezone.datetime.now()
blog.save() #객체 저장하기

Expand All @@ -40,6 +41,7 @@ def update(request, blog_id):
blog = get_object_or_404(Blog, pk = blog_id)
blog.title = request.GET['title'] #내용채우기
blog.body = request.GET['body']
blog.author = request.GET['author'] # 여기도 마찬가지!
blog.pub_date = timezone.datetime.now()
blog.save() #객체 저장하기

Expand Down
Binary file added blogProject/__pycache__/__init__.cpython-37.pyc
Binary file not shown.
Binary file added blogProject/__pycache__/settings.cpython-37.pyc
Binary file not shown.
Binary file added blogProject/__pycache__/urls.cpython-37.pyc
Binary file not shown.
Binary file added blogProject/__pycache__/wsgi.cpython-37.pyc
Binary file not shown.
12 changes: 0 additions & 12 deletions blogProject/settings.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
"""
Django settings for blogProject project.

Generated by 'django-admin startproject' using Django 3.0.6.

For more information on this file, see
https://docs.djangoproject.com/en/3.0/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.0/ref/settings/
"""

import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
Expand Down
Binary file modified db.sqlite3
Binary file not shown.
Binary file added myblog/myapp1/__pycache__/__init__.cpython-37.pyc
Binary file not shown.
Binary file added myblog/myapp1/__pycache__/admin.cpython-37.pyc
Binary file not shown.
Binary file added myblog/myapp1/__pycache__/models.cpython-37.pyc
Binary file not shown.
Binary file added myblog/myapp1/__pycache__/views.cpython-37.pyc
Binary file not shown.
Binary file not shown.
Binary file added myblog/myapp2/__pycache__/__init__.cpython-37.pyc
Binary file not shown.
Binary file added myblog/myapp2/__pycache__/admin.cpython-37.pyc
Binary file not shown.
Binary file added myblog/myapp2/__pycache__/models.cpython-37.pyc
Binary file not shown.
Binary file added myblog/myapp2/__pycache__/views.cpython-37.pyc
Binary file not shown.
Binary file not shown.
Binary file added myblog/myblog/__pycache__/__init__.cpython-37.pyc
Binary file not shown.
Binary file added myblog/myblog/__pycache__/settings.cpython-37.pyc
Binary file not shown.
Binary file added myblog/myblog/__pycache__/urls.cpython-37.pyc
Binary file not shown.
Binary file added myblog/myblog/__pycache__/wsgi.cpython-37.pyc
Binary file not shown.