[Answered ]-Django: How to use static files (simple case, jquery)


You need to read that documentation more closely. That warning is for production. In development, you do use that static-serving method, ie putting it in your urls.py. And, that documentation will also show that the templates directory is not the right place to put them: a separate static or media directory is.

Edit after comment I really don’t understand your comment. Either you do it in development via the static serving view, or you use your production server. But you say you don’t have a production server. When you get one, whether it’s Apache or Nginx or whatever, you put your static files in a directory and tell that server to serve files from there. That is the simple solution. The staticfiles app, exactly as in the docs you quoted, are for when you’ve got lots of files in different apps (and it simplifies the move from development to production, not complicates it as you seem to think).


Suppose your app is www.

  1. setting.py -> STATIC_ROOT = ‘static/’
  2. make dir www/static
  3. make file www/static/some.html
  4. in browser localhost:8000/static/some.html

That’s all.

Leave a comment