Django: Getting Started Transcripts
Chapter: HTML Templates
Lecture: Configuring static content
Login or purchase this course to watch this video and the rest of the course contents.
0:00 You'll need somewhere to put your static files. The usual place is a directory named static.
0:06 Let me create that and now I'll go into it and I'm going to copy a logo and fabric on file from the data directory in the code repo
0:24 I now have a static directory and some static files to serve from it. With those files in place, I now need to tell Django where to look for them.
0:32 You do that with some configuration. Let me open up settings.py. Now I'm going to scroll all the way down to the bottom.
0:42 The static URL configuration indicates the URL of where static files will be served from. If you're in a production model,
0:50 this will be the base of the URL that's something like Apache will serve those files from rather than Django.
0:57 In addition to this, I'm going to add the static files, dirs configuration setting. This is a touple that specifies all the places to look for
1:10 static files. In this case only one. Django uses this to serve the content from the DEV server and to manage the content
1:18 if you're exporting it into a production environment. Like the template dirs setting from earlier.
1:24 I've used base_dir as a reference point and reference that newly created static folder.
1:32 If your debug property in settings is true and you're using the DEV server. The static files found in this directory will now get served.
1:40 You don't have to do anything else. In production your debug property should be set to false and these should be being served by Apache
1:47 or nginx or something equivalent.