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
8.3k
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
210
The Life and Times of a React Component
matthewwithanm
1
170
Everyone's Happy: React, Server-side Rendering & SEO
matthewwithanm
2
1.2k
Conquering State
matthewwithanm
1
350
RequireJS in 15 Minutes
matthewwithanm
2
180
Other Decks in Programming
See All in Programming
Web フロントエンドエンジニアに開かれる AI Agent プロダクト開発 - Vercel AI SDK を観察して AI Agent と仲良くなろう! #FEC余熱NIGHT
izumin5210
3
560
XP, Testing and ninja testing ZOZ5
m_seki
3
720
bootcamp2025_バックエンド研修_WebAPIサーバ作成.pdf
geniee_inc
0
120
Building, Deploying, and Monitoring Ruby Web Applications with Falcon (Kaigi on Rails 2025)
ioquatix
4
2.2k
NixOS + Kubernetesで構築する自宅サーバーのすべて
ichi_h3
0
1k
3年ぶりにコードを書いた元CTOが Claude Codeと30分でMVPを作った話
maikokojima
0
550
実践Claude Code:20の失敗から学ぶAIペアプログラミング
takedatakashi
15
5.7k
iOSエンジニア向けの英語学習アプリを作る!
yukawashouhei
0
200
アメ車でサンノゼを走ってきたよ!
s_shimotori
0
230
kiroとCodexで最高のSpec駆動開発を!!数時間で web3ネイティブなミニゲームを作ってみたよ!
mashharuki
0
700
「ちょっと古いから」って避けてた技術書、今だからこそ読もう
mottyzzz
11
6.9k
CSC305 Lecture 05
javiergs
PRO
0
220
Featured
See All Featured
Building Applications with DynamoDB
mza
96
6.7k
Documentation Writing (for coders)
carmenintech
75
5.1k
Become a Pro
speakerdeck
PRO
29
5.6k
The Invisible Side of Design
smashingmag
302
51k
Leading Effective Engineering Teams in the AI Era
addyosmani
7
470
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
Designing for humans not robots
tammielis
254
26k
[RailsConf 2023] Rails as a piece of cake
palkan
57
5.9k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Visualization
eitanlees
149
16k
Embracing the Ebb and Flow
colly
88
4.9k
The Straight Up "How To Draw Better" Workshop
denniskardys
238
140k
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