Chapter 4. Create CRUD Web Application

STATIC_URL and STATICFILES_DIRS

STATIC_URL and STATICFILES_DIRS
Tag:

STATIC_URL defines the URL that is linked with the project directory location(s) defined by STATICFILES_DIRS. We'll explain how STATIC_URL and STATICFILES_DIRS work in this lesson.

The static directory is usually set directly under the project directory, but you can also set it under each app. You can set multiple static directories, and Django handles the static files in different static directories as if they are under the same directory.

For example, when there is an HTTP request 'localhost:8000/static/img-1.png' like in the main figure, Django gets the resource from the static directory under the project directory.

When there is an HTTP request 'localhost:8000/static/img-2.png', Django gets the resource from the static directory under the app_a directory.

STATIC_URL defines the URL that is linked with the project directory location(s) defined by STATICFILES_DIRS. We'll explain how STATIC_URL and STATICFILES_DIRS work in this lesson.

The static directory is usually set directly under the project directory, but you can also set it under each app. You can set multiple static directories, and Django handles the static files in different static directories as if they are under the same directory.

For example, when there is an HTTP request 'localhost:8000/static/img-1.png' like in the main figure, Django gets the resource from the static directory under the project directory.

When there is an HTTP request 'localhost:8000/static/img-2.png', Django gets the resource from the static directory under the app_a directory.

Tag: