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 q...
Search
Bruno Renié
April 14, 2012
Programming
4
550
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
450
Decentralization & real-time with PubSubHubbub
brutasse
1
160
Deployability of Python Web Applications
brutasse
17
2.3k
Stop writing settings files
brutasse
21
2.6k
Class-based Views: patterns and anti-patterns
brutasse
9
1.6k
Packager son projet Django
brutasse
4
560
Introduction to Django
brutasse
3
420
Other Decks in Programming
See All in Programming
CSC509 Lecture 10
javiergs
PRO
0
160
CSC305 Lecture 13
javiergs
PRO
0
340
Researchlyの開発で参考にしたデザイン
adsholoko
0
110
AI駆動開発カンファレンスAutumn2025 _AI駆動開発にはAI駆動品質保証
autifyhq
0
110
Migration to Signals, Resource API, and NgRx Signal Store
manfredsteyer
PRO
0
140
ボトムアップの生成AI活用を推進する社内AIエージェント開発
aku11i
0
1.4k
ネストしたdata classの面倒な更新にさようなら!Lensを作って理解するArrowのOpticsの世界
shiita0903
1
230
Vue 3.6 時代のリアクティビティ最前線 〜Vapor/alien-signals の実践とパフォーマンス最適化〜
hiranuma
2
360
AIのバカさ加減に怒る前にやっておくこと
blueeventhorizon
0
140
Making Angular Apps Smarter with Generative AI: Local and Offline-capable
christianliebel
PRO
0
100
GitHub Copilotを使いこなせ!/mastering_github_copilot!
kotakageyama
2
710
3年ぶりにコードを書いた元CTOが Claude Codeと30分でMVPを作った話
maikokojima
0
730
Featured
See All Featured
Docker and Python
trallard
46
3.6k
Large-scale JavaScript Application Architecture
addyosmani
514
110k
How to Ace a Technical Interview
jacobian
280
24k
Testing 201, or: Great Expectations
jmmastey
46
7.7k
RailsConf 2023
tenderlove
30
1.3k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
9.7k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
127
54k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
359
30k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
34
2.3k
Imperfection Machines: The Place of Print at Facebook
scottboms
269
13k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
658
61k
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