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
Django Static Stuff
Search
Matthew Dapena-Tretter
July 10, 2013
Programming
6
7.9k
Django Static Stuff
Handling the Un-Django Parts of Your Django App
Matthew Dapena-Tretter
July 10, 2013
Tweet
Share
More Decks by Matthew Dapena-Tretter
See All by Matthew Dapena-Tretter
Isomorphic JS, Server-side Rendering, React & Rockefeller
matthewwithanm
3
200
The Life and Times of a React Component
matthewwithanm
1
160
Everyone's Happy: React, Server-side Rendering & SEO
matthewwithanm
2
1.2k
Conquering State
matthewwithanm
1
340
RequireJS in 15 Minutes
matthewwithanm
2
180
Other Decks in Programming
See All in Programming
watsonx.ai Dojo #6 継続的なAIアプリ開発と展開
oniak3ibm
PRO
0
170
良いユニットテストを書こう
mototakatsu
11
3.6k
Androidアプリのモジュール分割における:x:commonを考える
okuzawats
1
280
ドメインイベント増えすぎ問題
h0r15h0
2
560
traP の部内 ISUCON とそれを支えるポータル / PISCON Portal
ikura_hamu
0
180
知られざるDMMデータエンジニアの生態 〜かつてツチノコと呼ばれし者〜
takaha4k
1
430
DevinとCursorから学ぶAIエージェントメモリーの設計とMoatの考え方
itarutomy
0
150
Swiftコンパイラ超入門+async関数の仕組み
shiz
0
170
混沌とした例外処理とエラー監視に秩序をもたらす
morihirok
13
2.3k
いりゃあせ、PHPカンファレンス名古屋2025 / Welcome to PHP Conference Nagoya 2025
ttskch
1
180
見えないメモリを観測する: PHP 8.4 `pg_result_memory_size()` とSQL結果のメモリ管理
kentaroutakeda
0
940
ゼロからの、レトロゲームエンジンの作り方
tokujiros
3
1k
Featured
See All Featured
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
Building an army of robots
kneath
302
45k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
28
4.5k
A Modern Web Designer's Workflow
chriscoyier
693
190k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
19
2.3k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.2k
The World Runs on Bad Software
bkeepers
PRO
66
11k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
Git: the NoSQL Database
bkeepers
PRO
427
64k
Into the Great Unknown - MozCon
thekraken
34
1.6k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.5k
Transcript
STATIC STUFF Handling the Un-Django Parts of Your Django App
Matthew Tretter @matthewwithanm
[email protected]
github.com/matthewwithanm http://speakerdeck.com/matthewwithanm/django-static-stuff
Photo by Jeff Prouse http://www.flickr.com/photos/prousefamily/426140767/ Static files used to be
a small problem for Django devs
Photo by John R. Southern http://www.flickr.com/photos/krunkwerke/267608325 Now, they’re a much
larger problem
None
⃠
None
⃠
None
Photo by Brin F http://thumbsandammo.blogspot.com/2013/03/blog-post_4297.html
⃠ {% load static %}
def static(path): return settings.STATIC_URL + path
{% load staticfiles %}
{% load static from staticfiles %}
{% load static from staticfiles %} Delegates to STATICFILES_STORAGE
main.css main.af42991c673a.css Wow, this slide is boring. CachedStaticFilesStorage CachedFilesMixin
You can’t tell your users to clear their cache Far-future
FTW Safer deployments Photo by patriziasoliani http://www.flickr.com/photos/55524309@N05/5378314720/
Why not django-compressor?
input defined in templates doesn’t know about dependency graphs only
for js & css
Embrace the build step Photo by Phyllis Buchanan http://www.flickr.com/photos/pgautier/2598157781/
1.Collect the static files from all apps into temporary location
2.Perform the build 3.Collect the built files Photo by Spencer Garness http://www.flickr.com/photos/njorthr/4030750472/
None
sass/lessc coffee uglify.js csso Photo by Toni http://www.flickr.com/photos/toniandmatthew/5212240990/
sass/lessc coffee uglify.js csso Photo by Toni http://www.flickr.com/photos/toniandmatthew/5212240990/ r.js jpegtran
pngcrush svgo
sass/lessc coffee uglify.js csso r.js jpegtran pngcrush svgo ANYTHING It’s
still the same photo
Can we do better? Yeah, still. Sorry.
Embrace Django
Photo by Brin F. But it’s slightly different than before!
No it’s not. http://thumbsandammo.blogspot.com/2013/03/blog-post_4297.html
generate & consume static file manifests tweak post-processing improve collection
TL;DL
{% load staticfiles %}
Hashes in Filenames
Embrace the build step
Build on staticfiles app
Thanks http://speakerdeck.com/matthewwithanm/django-static-stuff https://gist.github.com/matthewwithanm/5969795 Matthew Tretter @matthewwithanm
[email protected]
github.com/matthewwithanm