프로그래밍/Python

Django에서 static file (css,img 사용하기)

Terry Cho 2013. 11. 21. 23:29

django는 모듈화가 잘된건지. 웹개발에 최적화 된건지

여하간, tomcat처럼 디렉토리에 이미지나 CSS를 넣는다고 찾아지지 않는다.


(html) templates 처럼 특정 디렉토리를 생성하고 setting.py 파일에 지정해줘야 한다


setting.py에서

STATIC_URL = '/static/' 

해주고


각 app 디렉토리 밑에 /static이란 디렉토리를 만들어준다.

사용할 때는 load staticfiles를 불러준후에 경로를 다음과 같이 지정해주면 된다.


{% load staticfiles %}

this is group home

<img src="{% static "img/logo_nav.png" %}">


※ static file 경로 지정 방법 -https://docs.djangoproject.com/en/1.6/howto/static-files/


그리드형

'프로그래밍 > Python' 카테고리의 다른 글

Python 공부 노트 11. Module install  (0) 2014.01.02
Python에서 Open API 호출하기  (0) 2013.11.22
Django Template  (0) 2013.11.21
Django Hello World  (0) 2013.11.21
초경량 Python 웹서버 bottle을 이용한 MVC 예제 + Cookie  (0) 2013.05.03