Thanks Russell! I suppose the code I want to get looks like:
settings = Settings.objects.get(owner=userid) for switchable in ['groupon', 'companyon', 'addressfirst', 'extendnames', 'clubfieldson']: if switchable in data: settings._meta.get_field(switchable).<something> = True else: settings._meta.get_field(switchable).<something> = False My remaining question is, as you may have understood, what text do I use instead of <something> ? I imagine I could have been using a python function to list some options, but I was unable to find out how. I apologize for being stupid. Yours sincerely, Wim PS Another thing is, _meta is apparently a hidden function I am not supposed to be using. Do you recommend filing this conversation as a bug/feature request? Because I would be delighted when we could address object columns as settings['groupson'] = False, in order to open up all kinds of possible interactions. On Jun 10, 3:38 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]> wrote: > On Tue, Jun 10, 2008 at 9:25 PM,WimFeijen<[EMAIL PROTECTED]> wrote: > > > Coding happily away... > > > And wondering, can I write better code, using a loop, perhaps? In > > other words: can I set settings.groupon while using a variable in > > stead of groupon? > > > Thanks for any recommendations you are willing to make! > > Looks like you might want to have a look at the contents of > Settings._meta, also called the Options object. This object contains a > lot of meta-data about the class, such as the various names that can > be used to refer to the class, the fields on the class, and so on. The > meta object is available on the class and on instances. > > In particular, you're probably looking to iterate over > settings._meta.fields; each member of this list will be a Field > object, from which you can get field.name, field.attname, and many > other useful details. > > Yours, > Russ Magee %-) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---