Electronics & Programming


Open Source electronics development and programming

  • You are not logged in.

#1 June 19, 2010 18:52:29

Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

get item value in Field.__init__()

I have a form to edit my model. There is a select box in this form. By
default there are all the data in this select box. My goal is exclude
some data from select box, depending on current item data. So, to
achieve my goal, I need to know field value of the current model item
in the __init__ method of the field.

class StructureForm(ModelForm):
parent = ParentField()
class Meta:
model = Structure

class ParentField(forms.ChoiceField):
def __init__(self, *args, **kwargs):
kwargs =
super(ParentField, self).__init__(*args, **kwargs)

As you can see, there is a function "function_to_get_choices()" where
I have to provide CURRENT_ITEM_FIELD_VALUE and I don't know how to get
this value, please H E L P !

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


Board footer

Moderator control

Enjoy the 21st of March

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support