Introduction to Django: What is it and getting set up

Hello everyone! Today, I wanted to start a series on a Python framework I use every day: Django In this video, I'll go over what Django is and how to get it installed

So what is Django? Django is a web framework What's a framework? The best description I ever heard of a framework is that it's a collection of tools that you have to use in a specific way to get the best results So it's less like having a toolbox, and more like having a couple of modular kits from IKEA There's many possibilities to what you can do, but there's definitely limitations Even so, Django is still extremely flexible, allowing for a wide variety of websites to be built on top of it, from a simple blog to complex collections of data and features, like a newspaper

Let's get Django installed I'm going to assume that you have Python 3 and virtualenvwrapper installed already Using Python 3 is important, since Django will be phasing Python 2 out in the not-so-distant future First, we need to set up a virtualenv I'm going to be using Python 3, so I need to set that flag

Then, I'm going to pip install Django To make sure it worked, I'm going to type 'django-admin' I got help text rather than an error, so I know I'm good to go django-admin and managepy (which you'll see in a bit) are key in managing your Django app

They're what you'll use to create new projects and apps, migrate and dump data, and run the development server Now that we have Django set up, let's create a new project In your virtualenv, type `django-admin startproject` and then the name of your project I'm going to be calling my project "betterreads" (You'll see why in the next video) Django will create a new folder with a skeleton project inside of it

Let's go over what's in the project folder First, we have managepy As I said before, we'll be using this script quite a bit to help manage our project Second, we have a folder with the same name as our project

This folder is going to hold many of the settings that apply throughout our site Inside that folder, we have a number of files settingspy holds all of the settings for our site, like where our database is, where it can find templates, and so on urls

py holds all of the routing for our project, so that if someone goes to /blog, Django knows to serve up the front page to our blog and not our about me page wsgipy deals with serving up the site, and you wouldn't really mess with this file until you're ready to deploy your website Now that we know what all of these files are, let's get our database set up Run `python manage

py migrate`, and Django will create a new database some tables in it Once the database is set up, create a new super user by typing `python managepy createsuperuser` and following the prompts Now that we have a database, the last thing we have to do is to make sure everything is working by running the test server! Run `python managepy runserver`, then go to http://127

001:8000 in a browser You should see this test page If you go to 127

001:8000/admin/, you should see a login Use the super user you created earlier to log in If your login works, then everything is working! And that's all for this video! Next time, we're going to plan out our first app and create some models!