A
A
Artyom Innokentiev2016-03-13 17:31:15
Django
Artyom Innokentiev, 2016-03-13 17:31:15

What should be the structure of static files inside a Django project?

At the moment, the structure is:

static/
├── build
│   ├── css
│   │   └── main.css
│   ├── fonts
│   ├── images
│   └── js
│       └── main.js
└── src
    ├── blocks
    │   ├── footer
    │   └── header
    │       ├── header.js
    │       └── header.scss
    ├── fonts
    └── images

Working in src , building in build . We use BEM.
The structure is normal, but there are problems with bower dependencies . With js and css , everything is clear, everything is fine.
The problem with fonts and images - where should they be copied? Clearly, we are copying to src from bower_components . Copy fonts and images to src/fonts and src/images - so-so solution, there may be conflicts with names (the same image names for different bower dependencies ).
In my opinion there are two solutions:
src
    ├── blocks
    │   ├── footer
    │   └── header
    │       ├── header.js
    │       └── header.scss
    ├── dependency1
    ├── dependency2
    ├── fonts
    └── images

With this structure, we copy the fonts and images from the bower_components folder to the appropriate directory inside src . This raises two more questions: should the folder structure be kept inside the dependency (for example, dependency1/dest/assets/img/hello.png ) or should it be flattened ( dependency1/img/hello.png )?
Alternative structure:
src
    ├── blocks
    │   ├── footer
    │   └── header
    │       ├── header.js
    │       └── header.scss
    ├── fonts
    │   ├── dependency1
    │   └── dependency2
    └── images
        ├── dependency1
        └── dependency2

I think, in this case, everything is clear. Questions arise the same as in the structure above.
How to be?
PS I will be very glad to your structures or guides with best practices.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sim3x, 2016-03-13
@sim3x

Uncollected statics (+ jade ) - anywhere, better even outside the repository with the django project
Collected - in

└── myapp
    ├── manage.py
    ├── myapp
    │   ├── __init__.py
    │   ├── settings.py
    │   ├── urls.py
    │   ├── wsgi.py
    ├── requirements.txt
    ├── templates
    │   ├── css
    │   │   └── css.css
    │   ├── images
    │   │   └── image.png
    │   ├── index.html
    │   ├── js
    │   │   └── js.js
    │   ├── fonts
    │   │   └── font.svg

instead of bover it is better to use npm - less gestures and everything in one file along with assemblers, packages for tests, etc.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question