django_static_files Flashcards

1
Q

What are static files in Django?

A

Static files in Django include CSS, JavaScript, and image files that are used to enhance the appearance and functionality of a website.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Where should static files be stored within a Django app?

A

Static files should be stored in a folder named ‘static’ within the app’s root folder.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Why should you create subfolders for static files using the app name?

A

Creating subfolders using the app name helps to create name spacing for static files, preventing conflicts between files with the same name across different apps.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What setting is used to define additional directories for static files in Django?

A

The STATICFILES_DIRS setting in the Django project’s settings.py file is used to define additional directories for static files.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the purpose of STATICFILES_FINDERS in Django?

A

STATICFILES_FINDERS are used to locate static files in different locations, such as in app directories or other specified directories.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does the collectstatic command do in Django?

A

The collectstatic command collects all static files from various locations and stores them in the STATIC_ROOT directory for deployment.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the role of STATIC_ROOT in Django?

A

STATIC_ROOT is an absolute path that acts as the root location for all collected static files when deploying a Django app.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the purpose of STATIC_URL in Django?

A

STATIC_URL is a prefix for the URLs of static files, used to serve these files via a URL with the host and domain name.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How can static files be served in a Django project?

A

Static files can be served locally by the Django development server or remotely by a dedicated web server.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What command can be used to search for more relative paths containing static files in Django?

A

The findstatic command can be used to search for more relative paths containing static files.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the naming convention for folders under STATIC_ROOT after running collectstatic?

A

Folders under STATIC_ROOT are named after the app name to provide namespace separation, followed by folders for different types of static files like CSS and images.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How do you reference a static file URL in Django?

A

You reference a static file URL by combining the STATIC_URL prefix with the file path in the STATIC_ROOT folder, e.g., /static/onlinecourse/course.css.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly