Ian Ward's email:
first name at this domain
wardi on OFTC, freenode and github
In any web application user data must be translated from HTML form data to native types and database types, and back again. Django web applcations are no different.
The "right way" to handle custom types is to extend Django's widgets, form fields and model fields. However, understanding exactly how these types perform each step of the conversion can be confusing. This post will attempt to explain how the data is converted at each stage and offer some advice about creating custom widgets, form fields and model fields.
This article is based on Django 1.3 and assumes the reader has experience creating and using Django forms, models and validation.
The third iteration the Arevco Lighting web site is now up.
The old site was simple HTML and images generated from a script, which I quite liked but wasn't the easiest thing for other people to update. The new site has been professionally skinned and is now running a Django CMS with some custom index code for product pages. I used the following:
I've used Gerbi now for a few public web sites. It's a well designed and usable CMS that is quite easy to extend. It also has good multilingual support that will make translating content as easy as editing the pages.
If you write any custom Django widgets or admin list_display callable functions you have probably run into this: Everything looks ok, except the place where your widget should be is just blank. Nothing. No traceback or any clue as to what went wrong.
It seems that Django suppresses all the exceptions sent by widgets rendering except for AssertionError and TypeError. Debugging under those conditions is tricky, so I wrote a function decorator to help. Just import this and put @assert_on_exception before your render method or admin list_display callable function:
def assert_on_exception(fn):
import sys
def wrap(*args, **kwargs):
try:
return fn(*args, **kwargs)
except (AssertionError, TypeError):
raise
except:
assert 0, sys.exc_info()[0].__name__ + ": " + str(sys.exc_info()[1])
wrap.__name__ = fn.__name__
wrap.__dict__.update(fn.__dict__)
wrap.__doc__ = fn.__doc__
wrap.__module__ = fn.__module__
return wrap
This is the text from the Nontrivial Django Forms talk I gave last Tuesday at the April meeting of the Ottawa Python Authors Group.
This talk starts where the Django forms documentation leaves off.
Tags: Django Ottawa Software Python OPAG
Django's forms have fields like models, but you access them in a completely different way. I've found it hard to remember the correct way to access form field data properly, so this is a summary of the things I need to do with forms and how to do them. In particular these are useful in the form's __init__ method after calling super() to set up the form the way you want to.
Tags: Django
This is a video of the Django 1.1 talk I gave last night for the Ottawa Python Authors Group. We were bumped out of our reserved room so I did the talk in the pub. The timing worked out quite well, I just finished answering questions as game 6 was starting in the background.
Thank you to Andrew Ross and FOSSLC for doing the recording and setting everything up.
You will need Flash 10 to hear the audio for this presentation. If you don't like flash, please send a polite note to the ePresence people asking for them to support other formats.
Update: "we got screwed by the company we were dealing with for the software & hosting and the talk is lost" And sorry, I have no back-up either. The text from this talk is still available.
Tags: Django Ottawa Software Video Python FOSSLC OPAG
I will be giving my Django 1.1 talk at The Ottawa Python Authors Group meeting on Tuesday.
UPDATE: A video of my talk is now available
Tags: Django Ottawa Software Python OPAG
This is the text from the Django 1.1 talk I gave on Friday May 15 at Algonquin College for FOSSLC's Geocamp/Summercamp 2009.
I have tried to format this in a way that is well suited to skimming and easier to access from the web than reading the original slides. If you find this useful, please let me know.
Tags: Django Ottawa Software Python FOSSLC
I will be giving an introductory Django talk at The Free and Open Source Software Learning Centre (FOSSLC) Summercamp/Geocamp 2009 Conference. The conference is taking place on May 13, 14, and 15 at Algonquin College, Ottawa, Ontario, Canada, and early bird pricing is available until April 5.
Tags: Django Ottawa Linux Python FOSSLC