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
540
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
440
Decentralization & real-time with PubSubHubbub
brutasse
1
150
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
410
Other Decks in Programming
See All in Programming
フロントエンドオブザーバビリティ on Google Cloud
yunosukey
0
110
Amazon Bedrockマルチエージェントコラボレーションを諦めてLangGraphに入門してみた
akihisaikeda
1
190
The Price of Micro Frontends… and Your Alternatives @bastacon 2025 in Frankfurt
manfredsteyer
PRO
0
320
Generating OpenAPI schema from serializers throughout the Rails stack - Kyobashi.rb #5
envek
1
460
Boost Your Web Performance with Hyperdrive
chimame
1
170
変化の激しい時代における、こだわりのないエンジニアの強さ
satoshi256kbyte
1
890
自力でTTSモデルを作った話
zgock999
0
140
CSS Linter による Baseline サポートの仕組み
ryo_manba
1
170
推しメソッドsource_locationのしくみを探る - はじめてRubyのコードを読んでみた
nobu09
2
370
.NET Frameworkでも汎用ホストが使いたい!
tomokusaba
0
230
React 19アップデートのために必要なこと
uhyo
8
1.6k
Accelerate your key learnings of scaling modern Android apps
aldefy
0
100
Featured
See All Featured
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Designing Experiences People Love
moore
140
23k
How STYLIGHT went responsive
nonsquared
99
5.4k
GraphQLとの向き合い方2022年版
quramy
44
14k
Product Roadmaps are Hard
iamctodd
PRO
51
11k
Site-Speed That Sticks
csswizardry
4
420
Facilitating Awesome Meetings
lara
53
6.3k
Mobile First: as difficult as doing things right
swwweet
223
9.5k
Build The Right Thing And Hit Your Dates
maggiecrowley
34
2.6k
A designer walks into a library…
pauljervisheath
205
24k
Building an army of robots
kneath
303
45k
Done Done
chrislema
182
16k
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