What is django #1
a web application framework built with python
comes baked with many cool features to help with
- user authentication
- templating language
- routing . . .
allows us to eassily create dynamic web apps using python
Django(blog) tutorial #2
django-admin startproject project-name
init.py
settings.py
- control some different settings of my project
- templates or app setting usually path
urls.py
- control all the different routes or urls and sent user to different pages
manage.py
- allow it to spin up a server to make migration to enter some kind of interactive shell
Django tutorial #3 - URLs and Views
views response to browser
browser request to /about urls.py
urls.py
- looks at the request URL
- decides which function to fire in views.py
urls.py 안에 주소들이 담기고 그 주소에 해당하는 views를 보여주기 위해서
import . from views 를 해주고 .은 같은 디렉토리를 의미한다.
그 후에 views.py안에다 함수를 만들고 각 함수를 원하는 url이 호출 될때 함수를 실행하도록 설정해준다.
django templates에 html파일 실행 오류시
- 경로 확인
- 경로가 html파일이 위치한 폴더와 맞는지 확인한다.
- global하게 templates를 만들지 않고 app을 만들때 마다 templates를 만들거기 때문에 TEMPLATES안에 DIR = ['templates'] —> 항상 폴더 명을 templates로 하겠다는 의미.
- settings.py 에 app에 추가
- app이름을 INSTALLED_APPS = [ ..] 에 추가해준다