If I understood it correctly, you might want to do it like this

setattr(att, "fname", "value_to_be_set")

and to get the value

first_name = getattr(att, "fname")

On Mon, Nov 14, 2016 at 8:38 AM, rmschne <rmsc...@gmail.com> wrote:

> I have a extracted all the field names from a Django model into a list
> called "fields", e.g.
>
> fields = [(f.name, f.verbose_name) for f in Meetingattendee._meta.get_
> fields()]
>
> I ask the user to select a record, e.g.
>
> att=Meetingattendee.objects.get(id=attid)
>
> where "attid" is the ID of the record (input by the user)
>
> I now will ask user to input the name of the field of interest, e.g.
> "fname" which is one of the fields and holds "first name",  I then want to
> enable viewing/changing the selected field, e.g. in code to work with the
> first name field, it would be simply att.fname, but in this case the name
> of the field a string (input from user).  How to convert the input string
> name "fname" into something that in code would recognise that the user
> wants to work with att.fname?
>
> (hoping this question is clear!)
>
> --rms
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/df713caf-24f3-4309-b270-0b58e12c75cc%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/df713caf-24f3-4309-b270-0b58e12c75cc%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALn3ei2Lv5D-R_ih2eWu3TeGXLV2cXiSX1N%2Bcr21Zray7P_VJQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to