Project 1 - First Django App
This project will be completed in three distinct parts. Each part will be graded so that any problems can be fixed before they compound into larger problems.
- Project 1 - First Django App
- 1a - Create a Github repository - Due Mon, Aug 23
- 1b - Install Development Tools - Due Wed, Aug 25
- 1c - Build First Application - Due Fri, Aug 27
Project 1c - Build First Application - Due Fri, Aug 27
Goal - Build a simple Django project with one app, url, template, and view.
Step 1 - Activate the Virtual Environment
$ cd BACS350
Activate the Virtual Environment
$ pipenv shell
Step 2 - Start a project
Create a new directory
$ cd week1
$ mkdir Hello
$ cd Hello
Create a new Django project
$ django-admin startproject config .
Create the database
$ python manage.py migrate
Run the web server
$ python manage.py runserver
Browse to web page
http://localhost:8000
Step 3 - Start an app
Create an app called "pages"
$ python manage.py startapp pages
Add "pages" to INSTALLED_APPS in "settings.py"
Step 4 - Create a view
views.py
from django.http import HttpResponse
def homePageView(request):
return HttpResponse('Hello World')
urls.py
from django.urls import path
from .views import homePageView
urlpatterns = [
path('', homePageView)
]
Step 5 - Run server
Run the web server
$ python manage.py runserver
Browse to web page
http://localhost:8000
Step 6 - Commit your code
Add source to Git
$ git add .
Commit to repo
$ git commit -m 'Initial application'
Push the repo to Github
$ git push
Step 7 - Test your project
- Go to the Student Test Page
- Keep working until the page loads without errors
- No need to turn in the homework assignment. Grades will be determined from the content of your Github repo.