an app in a week
DESCRIPTION
A talk about creating web applications fast, given at Europython2008.TRANSCRIPT
An app in a week
http://marcinkaszynski.com
new site each monthrelease in a week
http://favpico.com/
http://webcomicspot.com/
http://oiola.com/
hey, cool,
it worked
!
created FAST
20 minutes7 days
decidebuild
rebuildthrow away
repeat
on to the work
The problem
it is cumbersome to gather the list of attendees to an
event
imprezra list of events
attendee registrations(oiola--)
General rules
1. avoid work
start with a framework
URL resolver/mapper
internationalization
form handling
templates
ORM
look for libraries
code only when absolutely necessary
directory: imprezr/
settings.py
urls.py
manage.py
settings.py
settings.py
urls.py
kickstart
commit early, commit often
development cycle starts
directory: events/
models.py
views.py
events/models.py
events/models.py
settings.py
fully functional admin interface
create, change, delete stuff
permission control
userX
customization
ModelAdmin:queryset – limit the list__call__ – add views
CSS, templates – change the looks
public views
/ - event list
/123/ - event details
/123/register/ - registration form
urls.py – generic views
templates/events/event_list.html
templates/base.html
templates/events/event_detail.html
event list
event detail
registration form
urls.py
events/views.py
templates/events/register.html
templates/events/event_details.html
cooperation
code sharing: only via VCS
Instant Django
theory:„everything you need to learn the basics
of the Django framework”
practice:the easiest way to share complete Django development environments on Windows
Python + Django + sqlite
Instant Django
1. checkout your source code2. add libraries (possibly using VCS, like
svn:externals)3. automate DB upgrades
„how should I call it?”„what did you call it?”„where did you put it?”
all mean lost time
conventions
example: template names
renders „app_name/view_name.html”
tests
they DO save time
some shortcuts – get, post, find
further reading
BeautifulSoup – navigation, searchingfindAll
testing the tests
coverage.py finds:untested code
dead code
false positives
small code changes requiredincredibly helpful anyway
first user responses
registration sucks:too little data (first name, last name)
events/models.py
events/views.py
add first_name and last_name
some ALTERing necessary
deseb
Django External Schema Evolution BranchADDs, ALTERs and DROPsworks around DB limitations
settings.py
adds new commands to manage.pysqlevolveevolvedb
evolvedb
flashback: Instant Django
1. checkout your source code2. add libraries (possibly using VCS, like
svn:externals)3. automate DB upgrades
broke the tests, too
events/tests.py
done
cycle continues
goto 10
user accounts
django-registrationdjango-userprofile
django-authopenid
openid
great for tech-savvy usersdifficult for other audiences
settings.py
urls.py
django_authopenid/views.py (twice)
1. copy django/contrib/admin/templates/admin/login.html
to imprezr/templates/admin/login.html
2. add the following form
the login page
the result
work avoidanceDjango user interface
conventionsInstant Django
testing the codetesting the tests
desebdjango_authopenid
summary
http://marcinkaszynski.com