Nick Efford avatar Nick Efford committed ee7af09

Added further slides and some screenshots.

Comments (0)

Files changed (3)

Added
New image
Add a comment to this file

slides/media/league.png

Added
New image

slides/slides.tex

+% Slides for Django tutorial at YPy Workshop, 11 December 2010
+% Nick Efford <nick.efford@gmail.com>
+
 \documentclass{beamer}
 
 \mode<presentation>
   \useinnertheme{circles}
 }
 
+\setlength{\leftmargini}{1.5em}
+\setlength{\leftmarginii}{1.5em}
+\setlength{\leftmarginiii}{1.5em}
+
+\newenvironment{itemize2}%
+ {\begin{itemize}%
+  \setlength{\topsep}{3pt plus 2pt minus 2.5pt}%
+  \setlength{\parsep}{0pt}%
+  \setlength{\itemsep}{3pt plus 2pt minus 3pt}}%
+ {\end{itemize}}
+
 \usepackage{times}
 \usepackage[T1]{fontenc}
 \usepackage{pgf}
 \usepackage{relsize}
 \usepackage{fancyvrb}
-
 \DefineShortVerb{\|}
 
 \title{Web Development With Django}
-\subtitle{An Introduction}
-
-\author[Nick Efford]{Nick Efford\\ \smaller\texttt{nick.efford@gmail.com}}
-\institute[Univ of Leeds]{School of Computing\\ University of Leeds}
-
+\subtitle{A Basic Introduction}
+\author[Nick Efford]%
+{
+Nick Efford\\
+\smaller
+\texttt{nick.efford@gmail.com}\\
+\href{http://pythoneering.blogspot.com/}{\texttt{pythoneering.blogspot.com}}\\
+\href{http://twitter.com/python33r}{\texttt{twitter.com/python33r}}
+}
+\institute[Leeds]{School of Computing\\ University of Leeds}
 \date[YPy 2010-12-11]{YPy Workshop, 11 December 2010}
-
 \subject{Web Development}
 
-% \pgfdeclareimage[height=0.5cm]{mylogo}{mylogo-filename}
-% \logo{\pgfuseimage{mylogo}}
-
-% Delete this if you do not want the table of contents to pop up at
-% the beginning of each subsection:
 \AtBeginSubsection[]
 {
   \begin{frame}<beamer>{Outline}
   \end{frame}
 }
 
-% If you wish to uncover everything in a step-wise fashion, uncomment
-% the following command: 
-
-%\beamerdefaultoverlayspecification{<+->}
-
 \begin{document}
 
 \begin{frame}
 
 \begin{frame}{Outline}
   \tableofcontents
-  % You might wish to add the option [pausesections]
 \end{frame}
 
+
 \section{Introduction}
 
+\subsection{Setting Up}
+
+
 \begin{frame}[fragile]{What You Will Need\ldots}
   \begin{itemize}
     \item Python 2.6 or 2.7
     \smaller
     \begin{minipage}{0.8\textwidth}
       \begin{alertblock}<2->{Note}
-        If you don't have Subversion \& Mercurial, we have CDs\ldots
+        If you don't have Subversion \& Mercurial, borrow one of my CDs
+        and copy the Django and tutorial directories from it \ldots
       \end{alertblock}
     \end{minipage}
   \end{center}
 \end{frame}
 
+\begin{frame}[fragile]{Setting Up Django For This Tutorial}
+  Two options:
+  \begin{itemize}
+    \item Go to main directory (the one containing |README|) and do
+      \begin{Verbatim}[gobble=6]
+        python setup.py install
+      \end{Verbatim}
+    \item Set |PYTHONPATH| to include main directory
+  \end{itemize}
+  \begin{center}
+    \smaller
+    \begin{minipage}{0.8\textwidth}
+      \begin{alertblock}<2->{Windows Users}
+        \textbf{Avoid spaces in pathnames!}
+        \par\vspace{0.5\baselineskip}
+        Try putting Django and tutorial code in |C:\tmp| or similar \ldots
+      \end{alertblock}
+    \end{minipage}
+  \end{center}
+\end{frame}
+
+
+\subsection{What Is Django?}
+
+
 \begin{frame}{What Is Django?}
   \begin{itemize}
     \item High-level framework for rapid web development
     \item Complete stack of tools
-      \begin{itemize}
+      \begin{itemize2}
         \item Data modelled with Python classes
-        \item Production-ready dynamic admin interface
+        \item Production-ready data admin interface, generated dynamically
         \item Elegant system for mapping URLs to Python code
         \item `Generic views' to handle common requests
         \item Clean, powerful template language
-        \item Components for user authentication, caching, syndication \ldots
-      \end{itemize}
+        \item Components for user authentication, form handling,
+          caching \ldots
+      \end{itemize2}
   \end{itemize}
 \end{frame}
 
+\note{
+Higher-level alternatives to traditional Java or C#/ASP.NET approaches
+are becoming increasingly popular -- PHP, Ruby on Rails, Django...
+
+Dozens of Python web frameworks, but only three or four significant ones --
+of which Django is the most successful.
+
+Cut-down version is used in Google App Engine!
+}
+
+\begin{frame}{A Working Example}
+  \begin{center}
+    \setlength{\fboxsep}{0pt}
+    \fbox{\pgfimage[interpolate=true,height=60mm]{media/league.png}}
+  \end{center}
+  \begin{center}
+    Football match results and league tables
+  \end{center}
+\end{frame}
+
 
 \section{Getting Started}
 
+\subsection{Project Structure}
+
+
+\begin{frame}[fragile]{Project Structure}
+  \textbf{Project}
+  \begin{itemize}
+    \item A Python package on your |PYTHONPATH|
+    \item Holds project-wide settings in |settings.py|
+    \item Holds a \textbf{URL configuration} (URLconf) in |urls.py|
+    \item Contains or references one or more \textbf{apps}
+  \end{itemize}
+
+  \vspace{\baselineskip}
+  \textbf{App}
+  \begin{itemize}
+    \item A Python package on your |PYTHONPATH|\\
+      (typically created as a subpackage of the project itself)
+    \item May contain \textbf{data models} in |models.py|
+    \item May contain \textbf{views} in |views.py|
+    \item May have its own URL configuration in |urls.py|
+  \end{itemize}
+\end{frame}
 
 \begin{frame}[fragile]{Creating Projects \& Apps}
-  \begin{enumerate}
-    \item Run |django-admin.py| to create a project
-      \begin{LVerbatim}[gobble=6]
-      django.admin.py startproject football
-      \end{LVerbatim}
-    \item Edit |settings.py| within project directory to define database, etc
-    \item Run |manage.py| within project directory to create directories for
-      each app
-      \begin{LVerbatim}[gobble=6]
-      ./manage.py startapp club
-      ./manage.py startapp league
-      \end{LVerbatim}
-  \end{enumerate}
+  Creating a project:
+
+  \begin{LVerbatim}[gobble=4]
+    django-admin.py startproject football
+  \end{LVerbatim}
+
+  \vspace{\baselineskip}
+  Creating an app within a project directory:
+
+  \begin{LVerbatim}[gobble=4]
+    cd football
+    ./manage.py startapp club
+  \end{LVerbatim}
 \end{frame}
 
+\begin{frame}{\texttt{settings.py}}
+\end{frame}
 
-\begin{frame}[fragile]{Data Models}
+
+\subsection{Data Handling}
+
+
+\begin{frame}{Data Models}
+\end{frame}
+
+\begin{frame}[fragile]{Example}
   \begin{Verbatim}[gobble=2,frame=single,fontsize=\relsize{-1}]
   from django.db import models
 
   \end{Verbatim}
 \end{frame}
 
+\begin{frame}[fragile]{Creating The Database}
+  \begin{enumerate}
+    \item Optionally check table creation SQL:
+      \begin{Verbatim}[gobble=6]
+        ./manage.py sql club
+      \end{Verbatim}
+    \item Sync installed apps with database:
+      \begin{Verbatim}[gobble=6]
+        ./manage.py syncdb
+      \end{Verbatim}
+    \item Optionally check the outcome in the database:
+      \begin{Verbatim}[gobble=6]
+        ./manage.py dbshell
+      \end{Verbatim}
+    \item Populate the database
+  \end{enumerate}
+\end{frame}
+
+\begin{frame}{Creating \& Saving Objects}
+\end{frame}
+
+\begin{frame}{Retrieving Objects}
+\end{frame}
+
+
+\subsection{The Admin Interface}
+
+
+\begin{frame}{The Admin Interface}
+  \begin{center}
+    \setlength{\fboxsep}{0pt}
+    \fbox{\pgfimage[interpolate=true,width=0.85\textwidth]{media/admin.png}}
+  \end{center}
+\end{frame}
+
+
+\section{Front-End Development}
+
+\subsection{Views}
+
+
+\begin{frame}{Generic Views}
+\end{frame}
+
+
+\begin{frame}{Writing a View Function}
+\end{frame}
+
+
+\subsection{Templates}
+
+
+\begin{frame}{Templates}
+\end{frame}
+
+
 \section*{Summary}
 
+
 \begin{frame}{Summary}
 \end{frame}
 
+\begin{frame}{Finding Out More}
+  \begin{itemize}
+    \item Project home\\
+    \url{http://www.djangoproject.com/}
+    \item Sites built using Django\\
+    \url{http://djangosites.org/}
+    \item Django developers\\
+    \url{http://djangopeople.net/}
+    \item Django-based rapid development platform
+    \url{http://pinaxproject.com/}
+    \item Apress books (\url{http://www.apress.com/})
+      \begin{itemize}
+        \item The Definitive Guide to Django (2nd edition)
+        \item Practical Django Projects (2nd edition)
+        \item Pro Django
+        \item Beginning Django E-Commerce
+      \end{itemize}
+  \end{itemize}
+\end{frame}
+
+\note{
+Packt also have several Django titles in print.
+}
+
 \end{document}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.