Your Ad Here

Wednesday, January 4, 2012

Django Form Field: BoundField question

Hi,

i'm using Django Version 1.3.1, can anyone say me why is the value
function in BoundField (FormField) makes a check if the value is
callable?

def value(self):
"""
Returns the value for this BoundField, using the initial value
if
the form is not bound or the data otherwise.
"""
if not self.form.is_bound:
data = self.form.initial.get(self.name,
self.field.initial)
if callable(data):
data = data()


I have a Field that encapsulates a Python Class, and this leads into a
problem because the value (a class definition) will be instatiated at
this time. But for a Dropdown field (wrapped by the TypedChoiceField
Field) this is not a neccessary action.

Can anyone say me what is the reason for having a datavalue callable
and call it on a field?

BR Sven

--
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