Django: Getting Started Transcripts
Chapter: Your First Django App
Lecture: Installing django

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Here I'm in my trusty terminal with a virtual environment activated, like most third party libraries. Django is available on PyPi, so I'm going to
0:08 use pip to install it and there it is. Django 4.0.2. with a few dependencies. packaged with Django is the Django
0:20 admin command. It is now available on your execution path. Let me run it here. Well, that was a lot, wasn't it? Let me just scroll this back up.
0:31 The Django Admin command doesn't do anything on its own besides print out help message to get something useful done.
0:37 You need to use a subcommand as I didn't use a subcommand, Django admin helpfully prints out all the possible choices I could use.
0:45 In a future lesson, I'll show you how to write your own subcommands and when you do they'll appear here as well.
0:51 The particular command I'm interested in right now is startproject. That's the one that creates a new project.
0:58 A project is where your code lives and will be the thing that outputs your web content to your users.
1:04 You might note that I'm being cagey here and I'm specifically not using the word application, even though that would make sense.
1:10 You'll see why I don't want to use that word in a minute. Let's run the startproject command creating a new project named Alexandria
1:18 after the famous historical library. I'll just scroll back down here and run the command.
1:28 The Django Admin command doesn't tell you anything once it has created the project, it just returns but if I look in my directory.
1:36 If you're a Windows person ls is the eunuchs equivalent of DIR. It lists the contents of a directory.
1:41 The start project subcommand creates the project directory using the name you passed in. In this case, Alexandria.
1:48 A bunch of files that define the base structure for the project get created for you. Let's take a look at them.
1:56 You may or may not have the tree command on your system. Don't worry about it. All it does is list the contents of a directory.
2:03 Inside of Alexandria there are two things. First confusingly, another directory named Alexandria.
2:09 I have never understood why the good folks at Django decided to use this double naming structure instead of calling it something like system,
2:17 but that's how it is. The inner Alexandria directory has five files in it which are key to running a Django server,
2:24 the ASGI and WSGI files are hooks for connecting Django to a web server such as Apache or nginx.
2:31 WSGI is a standard for this kind of interconnection and is short for web server gateway interface. ASGI is the asynchronous equivalent.
2:42 Unless you're doing something a bit more advanced you won't have to touch either of these files.
2:47 The other two files here will become like old friends by the time you're done with this course.
2:51, contains configuration for your web service, there are over 100 supported configuration settings in Django
2:58 and more get added when you install third party applications. The start project command sets up the mandatory settings and has some
3:05 reasonable defaults. The URLs file maps, URLs typed in the browser to the code that returns HTML for the browser to display.
3:15 You'll see more on this shortly. The outer alexandria directory has two things in it, the inner alexandria directory and a file.
3:25 The file is a local version of the Django admin with context specific subcommands.
3:31 You'll be using this to run a development server very soon.

Talk Python's Mastodon Michael Kennedy's Mastodon