[Django] render와 redirect 의 차이점
예를 들어서 상황을 한번 가정해보자. views에서 create이 후에 게시물 목록을 보여주기 위해서 render나 redirect를 할 건데, DB에 저장 후에 게시판이 뜨게 하고 싶다. views.py from django.shortcuts import render, redirect 기본적으로 위와 같이 import를 한다. render(request, 'article/index.html')을 하면, 바로 index.html로 넘어가기 때문에 DB가 없다. 따라서 index.html 로 넘어가도 게시물들이 안 뜬다. 하나의 함수는 하나의 기능만 가능하기 때문에 create함수에서는 DB를 저장 하기만 할 뿐, DB를 불러오기가 안된다. 즉, def index를 거쳐야 한다. redirect를 쓰면 u..
Web/Django
2020. 8. 1. 17:56
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- next.config.js
- DFS
- react
- useState
- login
- typescript
- 클라우데라
- read_csv
- pandas
- JavaScript
- vuejs
- 자연어처리
- UserCreationForm
- nodejs
- Queue
- Python
- Deque
- react autoFocus
- logout
- django
- TensorFlow
- BFS
- NextJS
- nextjs autoFocus
- useHistory 안됨
- Vue
- Express
- error:0308010C:digital envelope routines::unsupported
- mongoDB
- 자료구조
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
글 보관함