tags:

views:

43

answers:

1

Why do I have to either store my static content somewhere else, define some htaccess file or use the django.views.static.serve helper method? Why isn't it just done automatically? Other frameworks like ASP.Net doesn't seem to have that problem, even with the MVC Framework. The question is do other frameworks use something similar to django.views.static.serve behind the scenes? Or is it some limitation due to the current state of django code?

+4  A: 

Django doesn't 'block' paths to assets on disk - it just doesn't serve them by default.

It obviously can serve them, as you recognise by referring to static.serve. But the point is that, just as in any framework, this is not an efficient thing to do. There is a large amount of overhead involved in dealing with a request via Django, which simply isn't necessary when serving static assets. It's much better to let the webserver do it directly.

Django's choice of not enabling this by default is a warning to developers not to use this inefficient method in production.

Daniel Roseman
However any other MVC framework does this. It allows to fall back and let the server search the file and return 404 when it i snot found
the_drow
So why can't django do just that?
the_drow
But that's exactly what it does do: let the server search for the file. It doesn't handle it itself.
Daniel Roseman
@Daniel Roseman: But in any other framework you don't need to configure your server to search for it. Is it because of WSGI that needs to be disabled for the path? What about the internal server? Why doesn't it let access to static files without static.serve?
the_drow