2020년 3월 25일 보안정보 스크래핑

2020년 3월 25일 보안정보 스크래핑 3월 25일 보안정보 스크래핑 ==================================================================== + 주요 취약점 - 메일전송 프로토콜을 이용한 원격 명령어 실행 주의 권고 외 1건 1. 메일전송 프로토콜을 이용한 원격 명령어 실행 주의 권고 최근 OpenSMTPD* 취약점이 발견되는 등 메일전송 프로토콜에서 원격 명령어 실행이 가능하여 주의를 권고함 공격자는 취약점을 악용하여 피해를 발생시킬 수 있으므로, 해결방안을 참고하여 조치 필요 - https://www.krcert.or.kr/data/secNoticeView.do?bulletin_writing_sequence=35302 2. Django 제품 SQL Injection 취약점 보안 업데이트 권고 최근 Django*에서 SQL Injection취약점(CVE-2020-9402)을 악용할 수 있는 개념증명코드(Proof of concept, PoC)가 인터넷상에 공개되어 사용자의 보안 업데이트 필요 - https://www.krcert.or.kr/data/secNoticeView.do?bulletin_writing_sequence=35301 ==================================================================== + 취약점 - Apple Safari 취약점 1. Apple Safari 취약점 Apple Safari security bypass CVE-2020-3885 - https://exchange.xforce.ibmcloud.com/vulnerabilities/178339 Apple Safari security bypass CVE-2020-3887 - https://exchange.xforce.ibmcloud.com/vulnerabilities/178338 Apple Safari inform...

[django] python django 게시판 만들기 - Pagination

[django] python django 게시판 만들기 - Pagination

[django] python django 게시판 만들기 - Pagination

홈에 나오는 게시물들을 자른다!

-----------------------------------------------------------------------------------------------------------------------------------vscode 설치하기 : https://integer-ji.tistory.com/65

python 설치하기 : https://integer-ji.tistory.com/64

git 설치하기 : https://integer-ji.tistory.com/66

vscode 설정하기 : https://integer-ji.tistory.com/81

hello world 띄우기 : https://integer-ji.tistory.com/82

git 초기 설정 : https://integer-ji.tistory.com/83

page 이동 : https://integer-ji.tistory.com/84

word count 실습 ( 1 ) : https://integer-ji.tistory.com/85

word count 실습 ( 2 ) : https://integer-ji.tistory.com/86

python django 게시판 만들기 ( 1 ) : https://integer-ji.tistory.com/89

python django 게시판 만들기 ( 2 ) : https://integer-ji.tistory.com/90

python django 게시판 만들기 ( 3 ) : https://integer-ji.tistory.com/91

python django 게시판 만들기 ( 4 ) : https://integer-ji.tistory.com/93

python django 게시판 만들기 ( 5 ) : https://integer-ji.tistory.com/94

python django 게시판 만들기 ( 6 ) : https://integer-ji.tistory.com/95

python django 게시판 만들기 ( 7 ) : https://integer-ji.tistory.com/97

python django 게시판 만들기 ( 8 ) : https://integer-ji.tistory.com/99

python django 게시판 만들기 ( 9 ) : https://integer-ji.tistory.com/100

python django 게시판 만들기 ( 10 ) : https://integer-ji.tistory.com/101

python django 게시판 만들기 ( 11 ) : https://integer-ji.tistory.com/102

-----------------------------------------------------------------------------------------------------------------------------------

home 함수 수정

def home(request): blogs = Blog.objects.order_by('-id') blog_list = Blog.objects.all().order_by('-id') paginator = Paginator(blog_list,3) page = request.GET.get('page') posts = paginator.get_page(page) return render(request,'home.html', {'blogs':blogs,'posts':posts} )

paginator을 import 해줍니다.

home 함수를 변경할 건데 지금은 그냥 Blog의 객체 전부를 홈에 나타내 줍니다.

블로그 객체들을 blog_list에 새로 담고 paginator이란 변수에 Paginator를 이용해 3개씩 자른 blog_list를 넣어줍니다.

잘린 3개씩 들어있는 blog_list를 page에 넣어줍니다.

page를 출력하기 위해 posts에 넣어줍니다.

home.html 수정

{% extends 'base.html' %} {% block content %} {% for blog in posts %} {{ blog.title }} {{ blog.pub_date | date:"Y-m-d" }} {{ blog.summary }} ...자세히 보기 {% endfor %} {%if posts.has_previous%} First Previous {%endif%} {{posts.number}} of {{posts.paginator.num_pages}} {%if posts.has_next%} Next Last {%endif%} {% endblock %}

for blog in posts가 수정되었습니다.

블로그에 있는 모든 글을 가져오는 것이 아니라

3개로 잘린 page를 가져와야 합니다. posts로 변경

post.has_previous가 추가되었습니다.

만약 이전 페이지가 존재하지 않으면 나 타지 않습니다.

그리고 현재 페이지 번호와 총페이지를 나타내 줍니다.

다음은 다음 페이지를 나타내 줍니다. 마찬가지로 다음 페이지가 없으면 출력되지 않습니다.

확인

첫 페이지는 이전으로 갈 페이지가 없으니 if문이 실행되지 않습니다.

12페이지 중 2번째 페이지입니다.

마지막 페이지도 무사히 나옵니다.

git push

git init git add . git commit -m "코멘트"

git push origin master

---

빠르게 프로젝트에 진입하기 위해 진도부터 확 빼기

from http://integer-ji.tistory.com/106 by ccl(A)

댓글

이 블로그의 인기 게시물

엑스브레인(XBrain) 기업 정보

django 설치 방법

[aws] deploy Angular app with s3 | AWS S3로 angular 앱 배포하기