Django 튜토리얼

장고 튜토리얼 개발 정리

Django 튜토리얼 장고 튜토리얼 개발 정리

Part 6

Writing your first Django app, part 6

Github Tag:  

참고 자료

Static files?
Aside from the HTML generated by the server, web applications generally need to serve additional files — such as images, JavaScript, or CSS — necessary to render the complete web page. In Django, we refer to these files as “static files”.
Static file을 APP_NAME/static/APP_NAME/ 아래에 두는 이유

Static file namespacing

Just like templates, we might be able to get away with putting our static files directly in polls/static (rather than creating another polls subdirectory), but it would actually be a bad idea. Django will choose the first static file it finds whose name matches, and if you had a static file with the same name in a different application, Django would be unable to distinguish between them. We need to be able to point Django at the right one, and the best way to ensure this is by namespacing them. That is, by putting those static files inside another directory named for the application itself.

 {% load static %}은 최상단, <link ~> 부분은 <head> 태그 안에
{% load static %}

<link rel="stylesheet" type="text/css" href="{% static 'polls/style.css' %}">
 더 읽어보기
These are the basics. For more details on settings and other bits included with the framework see the static files howto and the staticfiles referenceDeploying static files discusses how to use static files on a real server.


댓글 본문
버전 관리
현재 버전
선택 버전
graphittie 자세히 보기