Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Getting started with Django

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on.

Getting started with Django

Conducted a workshop on 'Getting started with Django'.
Workshop details at http://www.meetup.com/Hyderabad-Python-Meetup-Group/events/127548232/
Code at https://github.com/akshar-raaj/workshop.

Avatar for Akshar Raaj

Akshar Raaj

July 06, 2013

More Decks by Akshar Raaj

Other Decks in Programming

Transcript

  1. Web Application • How is it different from static web

    pages. • Three tiers: Presentation, application and storage. • Request response cycle. • Finally browser expects an html document which the server must provide. Basic Python knowledge While we talk about basic python, install the following: • sudo apt-get install pip • sudo apt-get install virtualenv • Pip • Virtualenv • Datastructures: list, dict and tuple. If you write plain python • Have to connect to database. • Write raw sql. • Have to think about development server. • User management. • Need to create the admin. • Session management. • And hell lot of other things like templating, url mapping etc. Django While we talk about Django, set the environment: • virtualenv django polls. • pip install django • pip install ipython 1
  2. About Django • Web Application framework that supports rapid application

    development. • DRY principle. • Code reusability and Pluggability. • Has an ORM. • Provides a web server for development. • Provides admin for CRUD. • And once done with basic work, it supports advanced things like Feeds, sitemap, caching and what not. Start writing code • startproject • runserver and show default django page • syncdb • Enable the admin • CRUD on User model • Poll and Choice model and Queryset api • Basic views and urls • Use url and reverse instead of hardcoding. Keeps the code DRY • Changing the views • Associating User with Poll and Choice • Allow only logged in users to vote • Profile page for user 2
  3. If time permits Some best practises: • Prepend your app

    name to urls • Use relative imports • Use local settings Something more • Static files • Form • ModelForm • Any other topic you want 3