Hi,
How should I handle the display of reference properties via django
forms?
I have the two models below - and would like to show the
'DimensionForm' with a choice list of Library names. The definition
below errors on the subclass 'LibModelChoiceField' with ' issubclass()
arg 1 must be a class'.
The form and everything works fine until I try to preformat the
Library field.
Any advice very welcome. Thanks, Alex
class Library(db.Model):
#unique name of this library
name = db.StringProperty(required=True)
# description of this library
description = db.StringProperty(default='No description
available')
class Dimension(db.Model):
# unique name
name = db.StringProperty(required=True)
# belongs to one and only one library
library = db.ReferenceProperty(Library,
collection_name='dimensions')
class LibModelChoiceField(djangoforms.ModelChoiceField):
def label_from_instance(self, obj):
# Return a string of the format: "name, description"
return "%s , %s"%(obj.name, obj.description)
class DimensionForm(djangoforms.ModelForm):
library = LibModelChoiceField(Library.all())
class Meta:
model = Dimension
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en.