On 8/4/2010 5:26 AM, ars_sim wrote:
> 
> 
> Hello, Can anyone help me?
> 
> I have list of fields called 'allowed_fields' and I have object called
> 'individual'.
> allowed_fields is sub set of individual. Now I want to run loop like
> this
> 
> for field in allowed_fields:
> obj.field = individual.field
> 
> obj have same fields like individual. Do you have solution of my
> problem? I will thankful to you.
> 
> Regards,
> 
See the Python setattr() and getattr() functions. They allow you to
access attributes programmatically by name. I suspect you want

for field in allowed_fields:
    setattr(obj, field, getattr(individual, field))

regards
 Steve
-- 
I'm no expert.
"ex" == "has-been"; "spurt" == "drip under pressure"
"expert" == "has-been drip under pressure".

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

Reply via email to