Django in the real world Susan Ibach Christopher Harrison
Susan Ibach @hockeygeekgirl Senior Technical Evangelist, Microsoft Canada Data, code and cloud Longtime MCT Blogs at Canadian Developer Connection Runner and hockey mom @hockeygeekgirl
Christopher Harrison @geektrainer Senior Content Producer - Microsoft Virtual Academy Web guy <3 OSS Long-time Microsoft Certified Trainer Periodic blogger (blog.geektrainer.com) Marathoner, husband, father of one four-legged child @geektrainer
Agenda 1 Creating and managing a Django application 3 Forms and next steps 2 Security
Creating a Django application
Creating a Django application What are we about to create? What are the requirements? Why use Django?
What are we about to create? Application to manage a conference Display sessions, speakers and tracks
What are the requirements? Easy to navigate Partial page updates where appropriate Allow people to submit sessions They must register first Allow conference organizers to easily modify data Manage tracks Approve sessions Host in Azure
Why use Django? Built-in administration page Automatic form generation Easy to manage users and security Minimize code and effort
Installing Python & Django
Creating the project Getting started
Options for creating a Django project Use a Visual Studio template Use django-admin
What is django-admin Command-line utility for managing Django Create applications and apps Manage super users Migrate databases
Why use django-admin It's what the Django people use Ability to use templates Server-side libraries Authentication Security Client-side frameworks Single page apps Bootstrap
Using django-admin and Visual Studio Create empty Django project in Visual Studio Delete everything from the folder (except the proj & sln files) Use django-admin to create the project django-admin startproject <project-name> <containing-folder>
Creating a Django project
Creating the app
Using django-admin to create an app Why? Automatically creates: models.py views.py migrations Usage django-admin startapp <app-name> <folder-name> After creation Include folder in Visual Studio Add app as installed apps in settings.py
Creating a Django app
Creating the models
Object model Title Abstract Session Name Title Bio Speaker Title * Name Title Bio Speaker Title Description Track 1 1
Creating the models
Creating the database
Database management review makemigrations Create a new migration, this creates a package that contains all of the changes to be made to the database based on the code changes in our models sqlmigrate Display the SQL statements that will be applied by a migration migrate Update the database with the specified migration package
Getting the database setup