System notes ============ ~/.bashrc: alias cp='cp -i' alias mv='mv -i' alias rm='rm -i' alias ls='ls -F' alias ll='ls -lF' alias j=jobs alias k=kill ~/.vimrc: set ai sm sw=4 ts=8 expandtab map g G If you're using vi/m, learn to use it effectively: * Move char, word, line, to blank line, to top/middle/bottom of page, to top/bottom of file * x/X, dw, dd, * insert (new line) before/after current position * Change char/word/line * Global search and replace Linux: * Learn most common commands: directory navigation, job control, history, autoexpansion, input/output redirection, grep, file permissions, etc. * Keep simple, clear directory structures, e.g. ~/7401ICT/assign1/..., not ~/courses/7401ICT/assign1/mysite/... Databases: * Learn database shell commands * SQLite database (and directory containing the database) must be readable and writable (by the user running the (Django) server) * Design tables so that every table represents a single entity or a single relationship (BCNF) Django manage.py commands: validate syncdb shell dbshell runserver 0.0.0.0:8xxx (no need to know IP address) Django development: * Pay attention to detail! * Use examples. Don't start from scratch. * Learn your way around the Django documentation: - www.djangobook.com - docs.djangoproject.com * Learn to use generic views * Define __unicode__(self) in every model * Define get_absolute_url(self) in every model * Add django.contrib.admin and django.contrib.admindocs to INSTALLED_APPs to use admin * Use admin.py to register specific models with admin * Use forms.py or _forms.py to define forms * Learn to use ModelForm * Always give patterns names * Learn to use {{ object.get_absolute_url }}, {% url pattern_name %}, HttpResponseRedirect(reverse('pattern_name', args=(...))) * Development steps - Design URLs (/things/, /things/id/, /things/create/, /things/id/update/, etc.) - Design mapping from URLs to views (similar consistent naming scheme for views) - Design models - (Register models with admin) - Design forms (from models) - Implement views (when generic views are inadequate) - Design templates, use inheritance - Avoid absolute URLs everywhere except in URLconfs (urls.py) * Develop incrementally. Debugging: * Read error messages carefully. (They're not good, but they're better than PHP's.) * Include print statements liberally to see variable values, e.g.: print "variable =", variable. Output appears in server log, doesn't affect admin or public interface. * Divide and conquer to find errors, i.e., comment out blocks of code, repeatedly, to find location of error. * Think. Explain the problem to a friend. Last updated: $Date: 2008/09/11 07:49:44 $, by Rodney Topor