Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Staticfiles : tout ce qu'il faut savoir, rien que ce qu'il faut savoir
Search
Bruno Renié
April 14, 2012
Programming
4
530
Staticfiles : tout ce qu'il faut savoir, rien que ce qu'il faut savoir
Bruno Renié
April 14, 2012
Tweet
Share
More Decks by Bruno Renié
See All by Bruno Renié
Visibility for web developers
brutasse
3
430
Decentralization & real-time with PubSubHubbub
brutasse
1
140
Deployability of Python Web Applications
brutasse
17
2.3k
Stop writing settings files
brutasse
21
2.5k
Class-based Views: patterns and anti-patterns
brutasse
9
1.6k
Packager son projet Django
brutasse
4
550
Introduction to Django
brutasse
3
400
Other Decks in Programming
See All in Programming
OpenAPIを中心に考えるAPI開発入門 / Introduction to API Development with a Focus on OpenAPI
seike460
PRO
2
170
大規模UIKitベースアプリへのTCAの段階的導入/gradual-adoption-of-tca-in-a-large-scale-uikit-based-app
takehilo
2
200
"config" ってなんだ? / What is "config"?
okashoi
0
250
使ってみよう Azure AI Document Intelligence
kosmosebi
2
360
禅の心を手に入れよ
eltociear
1
280
Elm 0.19.0 Changes
bkuhlmann
0
500
効率化に挑戦してみたらモバイル開発が少し快適になった話
ryunakayama
0
140
FigmaとPHPで作る1ミリたりとも表示崩れしない最強の帳票印刷ソリューション
ttskch
43
19k
GraphQLサーバの構成要素を整理する #ハッカー鮨 #tsukijigraphql / graphql server technology selection
izumin5210
4
900
サイコロで理解する統計的仮説検定の考え方
tatamiya
4
1k
PostmanでAPIの動作確認が楽になった話
h455h1
0
180
MetricKitで予期せぬ終了を検知する話 / Detect unexpected termination with MetricKit
nekowen
1
200
Featured
See All Featured
Building Effective Engineering Teams - LeadDev
addyosmani
32
1.9k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
21
1.9k
YesSQL, Process and Tooling at Scale
rocio
165
13k
Facilitating Awesome Meetings
lara
43
5.6k
Building Applications with DynamoDB
mza
88
5.6k
A better future with KSS
kneath
231
16k
What’s in a name? Adding method to the madness
productmarketing
PRO
17
2.7k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
41
4.4k
Embracing the Ebb and Flow
colly
80
4.2k
Docker and Python
trallard
35
2.7k
Large-scale JavaScript Application Architecture
addyosmani
504
110k
Rebuilding a faster, lazier Slack
samanthasiow
74
8.2k
Transcript
Staticfiles tout rien que ce qu'il faut savoir Bruno Renié
Djangocong 2012
Django >= 1.4 django-staticfiles >= 1.2
MEDIA STATIC données dynamiques données statiques wat
STATIC_ROOT STATIC_URL STATICFILES_FINDERS STATICFILES_DIRS STATICFILES_STORAGE django-admin.py collectstatic
STATIC_ROOT STATIC_URL STATICFILES_FINDERS STATICFILES_DIRS STATICFILES_STORAGE django-admin.py collectstatic
Layout project/ app1/static/style.css app2/static/jquery.js app1 static app2 static
Configuration minimale # settings.py STATIC_URL = '/static/' # urls.py from
django.contrib.staticfiles.urls \ import staticfiles_urlpatterns urlpatterns += staticfiles_urlpatterns() # settings.py # urls.py
et c'est tout
Référencer un fichier {% load staticfiles %} {% static "jquery.js"
%} staticfiles static
app1/static/foo.css app2/static/foo.css {% static "foo.css" %} Conflits Comme les templates
foo.css foo.css "foo.css"
Namespaces Applications réutilisables / éviter les conflits app1/static/app1/foo.css app2/static/app2/foo.css {%
static "app2/foo.css" %} app1/foo.css app2/foo.css "app2/foo.css"
STATICFILES_DIRS Applications non-standard
En production # settings.py STATIC_ROOT = '/path/to/public/static' $ python manage.py
collectstatic # settings.py
et c'est tout
Cache busting STATICFILES_STORAGE = ( 'django.contrib.' 'staticfiles.storage.' 'CachedStaticFilesStorage' ) {%
static "foo.css" %} ↓ /static/foo.1cc9fe7eb4b9.css
{% static %} ♡ @brutasse