Tuesday, May 31, 2011

how to display a property in a ModelFormSet?

I'm using a ModelFormSet to display and edit multiple records. Some
of those records have related attributes that I want to display, but
not edit. E.g.

lineitem.quantity [editable] lineitem.product.description [not
editable]

So I thought I would add a property to my LineItem class in order to
render that in a ModelFormSet, like so:

def _get_product_description(self):
return self.product.description
product_description = property(_get_product_description)

But that wont get displayed when I render my FormSet.

Any tips on how to deal with this problem?

Thanks.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate