0

I have seen different ways in tutorials where the static files directory keep on changing.

1. Some put static files in the project root directory. Example

myproject
|__blog
|  |__migrations
|  |__static 
|  |__templates
mysite
|
static
   |__blog
         |__css
         |__js

2. Some put the static files in the root directory of the app it is serving. Example

myproject
├── blog
│   ├── migrations
│   ├── static
│   └── templates
└── mysite

Where should static files be located?

Ivan Starostin
  • 8,798
  • 5
  • 21
  • 39
  • 1
    The answer is whichever option suits you. If it is a standalone project I would go for option 1. If it is an app that is made for public use (a package others would use in their projects) one would use option 2. **Note**: At the end all static files are going to be collected in a common directory for production. – Abdul Aziz Barkat Mar 13 '21 at 16:23
  • 1
    The answer is both. You will have static files related to the project. Those go in the project static directory. The app-specific static files go in the static folder of the app. Remember to namespace static files. – Jarad Mar 13 '21 at 17:03

1 Answers1

0

It's whatever you want. Personally, I prefer to keep my static resources at one place instead of scattered in different applications. Moreover, most staticfiles are needed in multiple apps, so I just put everything one place and serve from there.

Chymdy
  • 662
  • 4
  • 14