Contents of Django Tutorial from pythonprogramming dot net

For me, the commands are entered into the Anaconda Prompt.

## Django Web Development with Python, Tutorial Series

Here's a link to the tutorial series. It's pretty great. It has both video and text versions of every part of the series. Here's a summary of each part:

### **Part 1, Introduction**

This part tells you what Django is, what it's like, and compares it to an alternative, called Flask.

Tells you how to install Django. Then tells you the first steps to create a project, and test that the basics worked.

To create project, Navigate via the terminal or command prompt to an area where you want to work on your project, then do:

```
django-admin startproject mysite

```

To test that this worked, navigate into the newly created folder (using cd mysite), then use the following code and visit the following site to see a success message http://127.0.0.1:8000

```
python manage.py runserver

```

### **Part 2, First Website**

This tutorial is focused on getting a simple page to render some text.

We do this by creating an app, putting text to display in its "views" file, and getting it a working url.

Navigate to your website folder using cd mysite, then add an app using:

```
python manage.py startapp webapp

```

Then modify webapp/views.py so that it has text to display on our website.  Then create webapp/urls.py and set it up to handle the url pattern.

Get the main project to point to the webapp by modifying mysite/urls.py to actually have the url for the webapp, and getting it to "include" webapp/urls.py.

Finally, add 'webapp', to the list in mysite/settings.py.

To test, runserver, and go to http://127.0.0.1:8000/webapp/ which should display the text successfully.  The tutorial then gives ways to get it to display at different urls, including the main one, and one with an extra slash.

### **Part 3, Jinja Templates**

[Link]  Builds a simple personal website.  This personal website has links to a few pages, including an "about me" page.

To do this, uses templates, html, and Jinja.  "Jinja is a Python templating engine, aimed at helping you to do dynamic things with your HTML like passing variables, running simple logic, and more!"

Also shows how to "include" little snippets into any page.

### **Part 4, design with HTML/CSS and Bootstrap**

[Link]  This tutorial is basically about making the website look nicer, mentioning things you can use instead of bootstrap for other contexts.

### **Part 5, Jinja Variables**

[Link]  "create our contact page, creating it as a generic page and passing the data for the block body as a variable from Python to the HTML template."  "passing variables from Python to our HTML templates."

In the transcript, he doesn't really say what this is good for (I guess just sometimes you need or want your python code to give stuff to your HTML, so here's how you do it), but it looks like more ways to make stuff appear here and there on the website.  Perhaps in a dynamic way.

At the end he says "**You can actually pretty much do anything from this point** by coding various functions yourself, like accessing a database to grab data and populating the dictionary that way."

### **Part 6, Beginning a Blog**

[Link]  Creates a blog.  Shows how to use "models".  Models contain meta-data, describe what is in your database, and can do other things too.

### **Part 7, Views and Templates (for the blog)**

[Link]  Still working on the blog.  Creates an HTML file for the blog.  Teaches more stuff about views and templates.  For example, ListView helps you display all the blog posts in sequence onto a page, like a list of them.

### **Part 8, Database migrations**

[Link]  Whenever you make a "model", you want to "migrate" it.  Basically makes sure all the changes you want to make actually happen in the database or whatever.  "Migrations are used any time you want Django to recognize changes to the models and database schema. Adding data to an existing database table, for example, is not something that needs a migration, changing that table's structure (by changing the model), would require a migration"

First, get the migrations ready by "making" them (what a misnomer) using the following (note that "blog" is just the app name):

```
python manage.py makemigrations blog

```

Then, check to make sure everything is good to go (he doesn't really say what you're looking for here, just "read it over" then move on.. if nothing stands out?  If what?):

```
python manage.py sqlmigrate blog 0001

```

Then, finally, actually perform the migrations:

```
python manage.py migrate

```

### **Part 9, Admin control panel**

[Link]  This admin control panel is an app that is installed by default in django projects.  This tutorial also adds blog posts.

To make a user profile for an admin:

```
python manage.py createsuperuser

```

Mentions some of the powers this admin user has, then tells you how to make it so that you can write blog posts in the actual website like a normal "real" website.  A GUI is already made for us to use.  To visit the page of an individual blog post, have to fix things in the next tutorial.

### **Part 10, Finishing blog**

[Link]  Talks about creating more dynamic urls, we need them to give a unique url for each blog post we create.  And we have to make an HTML file for this too, because none of our HTML files so far really look the way we want these pages to look.

### **Part 11, Publishing Django Project to a web server**

[Link]  Putting the project on a web server allows other people across the internet to visit the web page you made.  Doing this usually costs money.

### **Part 12, Securing Django web server with SSL - HTTPS and Lets Encrpyt**

[Link]  Exactly what it says on the tin...