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

For the third-party (jquery) code in my Django project, I adopted a directory structure for my static files, which put all the third-party files in a separate lib subdirectory. In particular, this is what my directory tree looks like now:

 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 intended to accomplish two things: 1. Separating my own assets from third-party assets. 2. Separation of css, img and js files.

Of course, as long as all the paths are correct, this works fine, but is there any agreement at all for posting third-party material in Django projects?

I also reviewed

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

I wonder if I can overdo it, but does he have a β€œbest practice”?

+6
source share
1 answer

The latter approach is much better.

  • You can simply unzip the third-party library and paste the folder. You do not need to manually copy and paste each file into different folders.
  • You can also use the front-end package management tool (which I recommend), for example, bower with a directory structure.
  • Perhaps you do not need to configure the structure of third-party directories on css, js and images. You can leave everything that he has.

If your project is a bit larger, you might consider creating a different directory for each of the applications you created.

This is the directory structure in which I usually 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/ 
+3
source

Source: https://habr.com/ru/post/982917/


All Articles