Django: Getting Started Transcripts
Chapter: HTML Templates
Lecture: Favicons and static redirects

Login or purchase this course to watch this video and the rest of the course contents.
0:00 When I created the directory I copied two files in a logo and a fab icon Pecans are one of the web's biggest hacks.
0:09 This is what happens when features get added to a browser without going through the standards process. If you're not familiar,
0:14 these are the little icons that show up in the browser's tab. Your browser expects your favorite Con U R. L. Two B slash favor con dot I C.
0:24 O. I just finished putting all the static content in the static directory associated with the URL Of the same name. To get the fabric on to work.
0:34 You'll need a little extra code. I'm gonna put that code inside of the inner alexandria. Earl's file. Django comes with some views out of the box,
0:47 One of which is a redirect view when it is hit it sends a 302 telling the browser to look somewhere else for the content.
0:56 The redirect view is in Django views generic base. Let me import it and now I can add a path specifically for the fabric keen
1:09 The views I've shown you so far are function based. Django also supports class based views.
1:17 The redirect view that I've just imported is actually a class based view with it being imported. I can now use it and put in a U. R. L. For the favor.
1:27 Con. Right inside of this line. I've directly in stan she hated the redirect view helper class. The URL
1:42 That I'm redirecting to is slash static slash Farrakhan dot I C. O. So to recap I registered A U. R. L. Called slash favor con dot I C O.
1:52 When it's hit it gets a 302 to go to slash static slash fabrikant dot I C O. And they're the static server can serve it like any other static file
2:03 Pecans are actually very tricky. You may need multiple files and multiple resolutions to make all the browsers happy.
2:12 The process for doing this is similar. You just need to add more files and more redirects.
2:17 There are also third party libraries that manage some of this to make your life a little easier with that logo and fabric on in place.
2:24 I can now hit these, you RLS directly in the background. I'll start up a DEV server and I can now go hit these images and there's
2:36 the logo and there's the fabric on and in fact up here in the corner you can see the browser's already using it.


Talk Python's Mastodon Michael Kennedy's Mastodon