Overview
Wednesday, January 21st
Classwork
We'll pick up where we left off last week - we're trying to create an entire view (with accompanying template) from scratch. We'll walk through this together and then you'll repeat the process on your own for homework.
For those who had trouble following along in class today, or just need a review, here's some commits you can review:
- Last class, we followed these steps:
- setup and activated a virtual environment
- installed django
- ran
python3 -m django startproject hello_django - cd'd into the
newly-created
hello_djangodirectory - ran
python3 -m django startapp core
http://localhost:8000/and see the rocket ship. - Today in class, we worked forward from there. We had to modify a few files and create a few more. Here is my commit that includes all of those changes
-
After those changes, you should be able to
python3 manage.py runserverand then navigate tohttp://localhost:8000/core/to see the word 'test', and then tohttp://localhost:8000/core/icecream/chocolateto see the icecream template with the variable "chocolate" filled in
I know this was a lot. Please try your best for homework. If you get stuck, commit your work and email me so I can take a look!
I also want you to be comfortable with the directory tree we discussed in class. Django can certainly be confusing at first - with all the multiple files that have the same names. Here's the tree we drew on the board today. There is a lot omitted from this diagram, these are the only files that I want you to know for now.
hello_django ├── core │ ├── templates │ │ └── core │ │ ├── icecream.html │ │ └── index.html │ └── urls.py ├── db.sqlite3 ├── hello_django │ ├── settings.py │ └── urls.py └── manage.py
Homework
You should make a total of **three** new templates (not counting our icecream example from Monday). Each template should:
- Be linked from your index.html page
- Take an input parameter, using the URL template example from Dr. Chuck's video, and display it in the template
This assignment is due before the start of class on Wednesday. We'll grade each-other's pages at the start of class on Wednesday.
