Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Django Basics Django Templates Static Assets

David Axelrod
David Axelrod
36,073 Points

Why is it uncool for python to serve our static files in production??

Kenneth mentioned that static files should be served though apache and friends but why is it bad to just leave python as the static file deliverer

David Axelrod
David Axelrod
36,073 Points

wow thats embarrassing haha sorry!

Christopher Ekin
Christopher Ekin
2,046 Points

Hi Kenneth/Chris,

Any chance of a workshop on good static file serving?

Thanks for a great course! Chris

Chris Freeman
Chris Freeman
Treehouse Moderator 68,423 Points

Hey Christopher Ekin, I'm sure with enough insisting and room on either Kenneth Love's or Lacey Williams Henschel's schedule, a course will happen some day. I would too would like to see a course or workshop of handling static files for both development and production. Including file organization and using collectstatic.

2 Answers

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,423 Points

The tactic of using a different process or a different server for static assets apply to all web services independent of whether you're using Python. The biggest concern is loading on the main server dishing up the HTTP responses. This is often time the bottleneck in performance. By using the web interface (Apache, Nginx), or better yet serving it from a different Content Delivery Network (CDN), such as S3, the of serving static file is removed.

For small sites that aren't concerned by heaving loading, the overhead of serving the file locally may not matter.

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

The time it takes Python to go to the file system, find the file, figure out what filetype it is, serve it w/ the correct headers, and then get back to doing the work Python actually needs to do isn't insignificant. For a lot of sites, it's not a big deal, like Chris Freeman said, but, if you can not do it, all the better. Your site will run faster and you'll have one less thing for Python to worry about.

Erika Suzuki
Erika Suzuki
20,299 Points

A little tutorial on how to deploy Django with web servers such as Apache or Nginx will be so awesome. I made a working (at least with debug on) Django application but im having problems with deploying it. Tutorials on deploying it on a shared hosting server will also be extremely helpful. Just saying.