Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the recommended directory layout for third-party static files in Django projects?

For third-party (jquery) code in my Django project, I've adopted a directory structure for my static files that puts all third-party files in a separate lib sub-directory. More specifically, this is what my directory tree currently looks like:

myproject/
  myproject/
    static/
      css/
        my-own-stylesheet.css
        lib/
          bobs-stylesheet.css
          joes-stylesheet.css
      img/
        my-own-image.png
        lib/
          bobs-image.png
          joes-image.png
      js/
        my-own-javascript.js
        lib/
          bobs-javascript.js
          joes-javascript.js

This is meant to accomplish two things: 1. Separating my own assets from third-party assets. 2. Separating css, img, and js files.

Of course, as long as the paths are all correct, this works fine, but is there actually a convention for a location for third-party material in Django projects?

I've also considered

myproject/
  myproject/
    static/
      css/
      img/
      js/
      lib/
        bob/
          css/
          img/
          js/
        joe/
          css/
          img/
          js/

I wonder if I may be overthinking this, but is there a "best-practice" for this?

like image 931
coder123 Avatar asked Feb 24 '15 00:02

coder123


1 Answers

The last approach is much better.

  1. You can simply unzip the third party library and paste the folder. You need not manually copy and paste each file to different folders.
  2. You can also use front-end package management tool (which I recommend) like bower with the directory structure.
  3. You may not need to tweak the third party directory structure into css, js and images.. You can leave whatever it has.

If your project is a bit larger, you may consider creating a different directory for each of the apps you have created.

This the directory structure which I generally follow:

myproject/
  myproject/
    static/
      my_app_1
        css/
        img/
        js/
      my_app_2
        css/
        img/
        js/
      lib/
        bob/
          what_ever_directory_str_it_has
        joe/
          css/
          img/
          js/ 
like image 167
Sudip Kafle Avatar answered Sep 30 '22 18:09

Sudip Kafle