Django Static Files Development

Based on what you’ve posted so far, it looks like you’re following the docs for django.contrib.staticfiles. I agree that the docs can be difficult to follow especially if one is new to django. I believe the confusion stems from the fact that django.contrib.staticfiles has two modes of operation: During the development phase where the development … Read more

Prevent IIS from serving static files through ASP.NET pipeline

I’m taking a guess here and suspect that you have the following setting configured in your web.config file: <modules runAllManagedModulesForAllRequests=”true”> This means that every request, including those for static content is hitting the pipeline. Change this setting to: <modules runAllManagedModulesForAllRequests=”false”> This is assuming your application is running under ASP.NET 4.0 and MVC3. For this to … Read more

Route to static file in Play! 2.0

IIRC, change <link rel=”stylesheet” media=”screen” href=”https://stackoverflow.com/questions/9792875/@routes.Assets.at(“stylesheets/main.css”)”> To <link rel=”stylesheet” media=”screen” href=”https://stackoverflow.com/questions/9792875/@routes.Assets.at(“stylesheets/”, “main.css”)”> I am talking about your third attempt Also, watch out for extra / EDIT GET /assets/main.css controllers.Assets.at(path=”/public”, file=”/stylesheets/main.css”) Assuming your resource is at /public/stylesheets/main.css

Learning Node – Express Public folder not working

The full URL I am trying to request: http://localhost:1337/public/serveme.txt That’s your problem. Anything inside the directory you designate as static content is made available directly from the base URL. You need to request http://localhost:1337/serveme.txt instead. If you want to only serve static files from /public you can pass a string as the first argument: application.use(“/public”, … Read more

Where to run collectstatic when deploying django app to heroku using docker?

After confirming with Heroku support, this does indeed appear to be a bit of a catch-22. The solution was to put collectstatic in the Dockerfile so that it runs during build time and the files persist. We got around not having a secret key config var by setting a default secret key using the get_random_secret_key … Read more

What’s the better approach: serving static files with Express or nginx?

for development: express, mainly because of flexibility it provides… you can change your static location and structure very easily during development for production: nginx, because its much much faster. Node/express are good for executing logic, but for serving raw content… nothing can beat nginx. You also get additional capabilities such as gzip, load balancing… Nevertheless, … Read more

Django — Can’t get static CSS files to load

Read this carefully: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/ Is django.contrib.staticfiles in your INSTALLED_APPS in settings.py? Is DEBUG=False? If so, you need to call runserver with the –insecure parameter: python manage.py runserver –insecure collectstatic has no bearing on serving files via the development server. It is for collecting the static files in one location STATIC_ROOT for your web server to … Read more

Use nginx to serve static files from subdirectories of a given directory

It should work, however http://nginx.org/en/docs/http/ngx_http_core_module.html#alias says: When location matches the last part of the directive’s value: it is better to use the root directive instead: which would yield: server { listen 8080; server_name www.mysite.com mysite.com; error_log /home/www-data/logs/nginx_www.error.log; error_page 404 /404.html; location /public/doc/ { autoindex on; root /home/www-data/mysite; } location = /404.html { root /home/www-data/mysite/static/html; } … Read more