I have set up a relationship between two tables as shown below:
class Plant(Base):
__table__= Table("plant1", Base.metadata,
autoload=True, autoload_with=engine)
proj = relationship("Projection")
def __unicode__(self):
return self.common
class Admin(EntityAdmin):
list_filter = ["plant_type"]
list_search = ["common"]
form_size = (400,200)
list_display = ["common", "genus", "species", "plant_type",
"season"]
form_display = ["common", "genus", "species", "plant_type",
"season",
"proj"]
form_size = (500, 300)
class Projection(Base):
__table__ = Table("projection", Base.metadata,
autoload=True, autoload_with=engine)
plant = relationship("Plant")
class Admin(EntityAdmin):
form_size = (400,200)
field_attributes = {"qty": {"precision": 2}}
list_display = ["year", "qty", "plant"]
I get a form view where I have many projections for each plant, which is
what I want. What I am trying to figure out is how to have the
p_item_no(FK) filled in automatically from the plant when I create a new
record in the form?
On a somewhat related note I get the following error when I run the form:
ERROR:camelot.admin.validator.object_validator:programming error while
validating object
Traceback (most recent call last):
File
"/usr/local/lib/python2.7/site-packages/Camelot-12.06.29-py2.7.egg/camelot/admin/validator/object_validator.py",
line 165, in isValid
messages = self.objectValidity(entity_instance)
File
"/usr/local/lib/python2.7/site-packages/Camelot-12.06.29-py2.7.egg/camelot/admin/validator/object_validator.py",
line 106, in objectValidity
return self.validate_object( entity_instance )
File
"/usr/local/lib/python2.7/site-packages/Camelot-12.06.29-py2.7.egg/camelot/admin/validator/entity_validator.py",
line 45, in validate_object
return super( EntityValidator, self ).validate_object( obj )
File
"/usr/local/lib/python2.7/site-packages/Camelot-12.06.29-py2.7.egg/camelot/admin/validator/object_validator.py",
line 135, in validate_object
elif (attributes['delegate'] == delegates.Many2OneDelegate) and
(not
value.id):
AttributeError: 'Plant' object has no attribute 'id'
My guess is occurring because I am using a reflected table and it does
not have an id column. It does have p_item_no which is the PK. Is there
a way to either turn of that particular validation or tell the framework
the actual PK?
Thanks,
--
Adrian Klaver
adr...@aklaver.org