On Wed, Jul 23, 2008 at 07:50:47PM +0000, Matthew Wilson wrote:
> I have an employees table and a departments table, and every employee
> has a foreign key to the departments table.
> 99% of the time, new employees belong to one particular department,
> How can I make the SALES department the default department for new
> I tried this:
> class Department(SQLObject):
> name = UnicodeCol(alternateID=True)
> class Employee(SQLObject):
> user_name = UnicodeCol(alternateID=True)
> department = ForeignKey(default=Department.byName("SALES")
> And it failed.
In what way? For .byName() to work Department.name must be an
alternateID column (which implies uniqueness).
This works for me:
name = StringCol(default=None, alternateID=True)
name = StringCol(default=None)
department = ForeignKey('Department', default=Department.byName('Sales'))
Oleg Broytmann http://phd.pp.ru/ phd@...
Programmers don't die, they just GOSUB without RETURN.