$30 off During Our Annual Pro Sale. View Details »
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
460
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
570
Introduction to Django
brutasse
3
420
Other Decks in Programming
See All in Programming
生成AIを利用するだけでなく、投資できる組織へ
pospome
0
160
無秩序からの脱却 / Emergence from chaos
nrslib
2
13k
SwiftUIで本格音ゲー実装してみた
hypebeans
0
100
開発に寄りそう自動テストの実現
goyoki
1
740
「コードは上から下へ読むのが一番」と思った時に、思い出してほしい話
panda728
PRO
37
25k
AIエージェントを活かすPM術 AI駆動開発の現場から
gyuta
0
350
CSC305 Lecture 17
javiergs
PRO
0
340
AIコーディングエージェント(Manus)
kondai24
0
160
認証・認可の基本を学ぼう前編
kouyuume
0
190
WebRTC、 綺麗に見るか滑らかに見るか
sublimer
1
160
Microservices rules: What good looks like
cer
PRO
0
1.1k
sbt 2
xuwei_k
0
250
Featured
See All Featured
[RailsConf 2023] Rails as a piece of cake
palkan
58
6.1k
Scaling GitHub
holman
464
140k
Git: the NoSQL Database
bkeepers
PRO
432
66k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
The Cult of Friendly URLs
andyhume
79
6.7k
Java REST API Framework Comparison - PWX 2021
mraible
34
9k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
359
30k
What's in a price? How to price your products and services
michaelherold
246
12k
Building a Scalable Design System with Sketch
lauravandoore
463
34k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
A Modern Web Designer's Workflow
chriscoyier
698
190k
Producing Creativity
orderedlist
PRO
348
40k
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