Re: How to pass List to Form Meta Class

2010-06-07 Thread Bill Freeman
If I understand you correctly, this is difficult.

If there are just a few possible value sets for "fields" it is better to make
several form classes, one for each subset of the fields that you will need,
and choose which form to instantiate depending on which set of fields you
want.

Note: The order of fields in the Feta class fields object does not affect the
order of fields on the page.

If the set of fields is truely dynamic, you will need, I believe, to
use internal
interfaces of the forms machinery, which are not guaranteed to remain the
same from one Django version to the next.

Bill

On Sat, Jun 5, 2010 at 1:58 PM, ars_sim  wrote:
> Hello All,
> I am newbie in django and I will very thankful to you if you help me
> in this regard.
>
> I want to pass list of fields from view to Meta class of FormModel.
> Please check this example.
>
> view.py:
>   fields = [name, email, phone]
>   individual_form = IndividualForm(fields)
>
> forms.py
> class IndForm(forms.ModelForm):
>   class Meta:
>        model = Ind
>        fields = (
>            'name',
>            'email',
>            'phone',
>        )
>
> I want to access view fields array into forms Meta class. I am not
> sure I can do this or not.
> Any idea! how can I do this?
>
> Regards,
>
> --
> 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 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



How to pass List to Form Meta Class

2010-06-05 Thread ars_sim
Hello All,
I am newbie in django and I will very thankful to you if you help me
in this regard.

I want to pass list of fields from view to Meta class of FormModel.
Please check this example.

view.py:
   fields = [name, email, phone]
   individual_form = IndividualForm(fields)

forms.py
class IndForm(forms.ModelForm):
   class Meta:
model = Ind
fields = (
'name',
'email',
'phone',
)

I want to access view fields array into forms Meta class. I am not
sure I can do this or not.
Any idea! how can I do this?

Regards,

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.