Background Image
Table of Contents Table of Contents
Previous Page  156 / 478 Next Page
Information
Show Menu
Previous Page 156 / 478 Next Page
Page Background

workspace

│ ├── superlists

│ │ ├── lists

│ │ │ ├── models.py

│ │ │

│ │ ├── manage.py

│ │ ├── superlists

│ │

│ ├── static

│ │ ├── base.css

│ │ ├── etc...

The logic is that the static files folder shouldn’t be a part of your repository—we don’t

want to put it under source control, because it’s a duplicate of all the files that are inside

lists/static

.

Here’s a neat way of specifying that folder, making it relative to the location of the

settings.py

file:

superlists/settings.py (ch07l018).

# Static files (CSS, JavaScript, Images)

#

https://docs.djangoproject.com/en/1.7/howto/static-files/

STATIC_URL

=

'/static/'

STATIC_ROOT

=

os

.

path

.

abspath

(

os

.

path

.

join

(

BASE_DIR

,

'../static'

))

Take a look at the top of the settings file, and you’ll see how that

BASE_DIR

variable is

helpfully defined for us. Now let’s try running

collectstatic

:

$

python3 manage.py collectstatic

You have requested to collect static files at the destination

location as specified in your settings:

/workspace/static

This will overwrite existing files!

Are you sure you want to do this?

Type 'yes' to continue, or 'no' to cancel:

yes

[...]

Copying '/workspace/superlists/lists/static/bootstrap/fonts/glyphicons-halfling

s-regular.svg'

74 static files copied to '/workspace/static'.

And if we look in

../static

, we’ll find all our CSS files:

$

tree ../static/

../static/

├── admin

│ ├── css

128

|

Chapter 7: Prettification: Layout and Styling, and What to Test About It