Electronics & Programming


Open Source electronics development and programming

  • You are not logged in.

#1 June 16, 2010 17:13:35

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

Django access data passed to form


I have got a choiceField in my form, where I display filtered data. To
filter the data I need two arguments. The first one is not a problem,
because I can take it directly from an object, but the second one is
dynamically generated. Here is some code:

class GroupAdd(forms.Form):
def __init__(self, *args, **kwargs):
self.pid = kwargs.pop('parent_id', None)

super(GroupAdd, self).__init__(*args, **kwargs)

parent_id = forms.IntegerField(widget=forms.HiddenInput)
choices = forms.ChoiceField(
choices = [
for group in
type_id =
ObjtreeTypes.objects.values_list('type_id').filter(name = 'group'),
parent_id = 50
).distinct()] + [
widget = forms.Select(
attrs = {
'id': 'group_select'

I would like to change the parent_id that is passed into the
Objtree.objects.filter. As you can see I tried in the init function,
as well with kwargs and then calling it with
self, but that doesnt work, since its out of scope... it was pretty
much my last effort. I need to acccess it either trough the initial
parameter or directly trough parent_id field, since it already holds
its value (passed trough initial).

Any help is appreciated, as I am running out of ideas.

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 20th of October

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