Lesson 2 - Django Projects & Apps
LEARN
Reading - Django for Beginners
- Chapter 2 - Hello World App
Github
- Github is the best version control service available
- It is a web service that hosts thousands of users and millions of projects
- By January 2020 - 40 million users, over 100 million repositories
Git
- Invented by the creator of Linux
- Save every version of every file
- Work individually or with thousands of developers
- Put everything under version control
Using Github
- All assignments will be completed using Github
- All pages you create will be saved in your Github repo
Virtual Environments
- You may need many different Python environments for different packages
- Each environment may use different packages
- Python provide Virtual Environments to isolate projects from each other
Activate Virtual Environment
- All work in Python should be done in a VENV
- Each work session starts by activating the environment
- This lets you use different libraries for each project
BUILD
Development Workflow
- Edit - make a small (1-3 lines) change to your code
- Test - run the server and browse to page
- Commit - commit changes every hour
- Repeat - work in small iteration, don't ignore bugs
Install Python Code Editor
- Install Visual Studio Code if needed
- Download and install on your machine
- Run Visual Studio
Tiled Windows
- Editor - Brackets
- Terminal - Run Django Server and file commands
- Browser - Instructions, Test Page, Github, BACS 350
Create New Project
Activate the Virtual Environment
$ cd BACS350
$ pipenv shell
Create a new directory
$ cd week1
$ mkdir Hello
$ cd Hello
Create a Django project
$ django-admin startproject config .
Run Development Server
Run the web server
$ python manage.py runserver
Don't worry about the warning for "unapplied migrations"
Browse to web page
http://localhost:8000
You should see
Use Ctrl-C to kill the server
Commit Your Code
Git add
$ git add .
$ git status
Git commit
$ git commit -m 'Create Hello app'
$ git status
Get push
$ git push
$ git status
Project 1 - Part B
- Complete Project 1 B Instructions
Commit all of your code and push
Next Lesson
Configure a Django project and build views