Serve static files in a better way

Andres Riancho avatarAndres Riancho created an issue

def sphinx_serve(request, slug, type_, path): isn't following Django's best practices for static content.

Static content shouldn't even be served by Django, and django-sphinxdoc is encouraging this bad practice. Also, things like "collectstatic" to get all static files and store them in a different domain (Amazon S3, dedicated varnish server for static files, CDN, etc. as explained here) won't work.

The sphinx_serve view uses a highly descouraged Django feature, from django's documentation:

During development, this will be done automatically if you use runserver and DEBUG is set to True (see django.contrib.staticfiles.views.serve()).

This method is grossly inefficient and probably insecure, so it is unsuitable for production.

A potential solution would be to: * Remove the sphinx_serve view * Override the collectstatic management command to fetch the files from the sphinx projects configured in the DB (this would be good for production environments) into the "static" folder configured in

There was an interesting discussion about collectstatic in the django-developers mailing list.

Still unsure how to fix this for dev environment (runserver) but someone with more django experience will figure it out :)

Comments (0)

  1. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.