On Fri, May 25, 2012 at 6:42 AM, bruno desthuilliers <bruno.desthuilli...@gmail.com> wrote: > On May 25, 2:32 pm, Larry Martell <larry.mart...@gmail.com> wrote: >> On Fri, May 25, 2012 at 2:24 AM, bruno desthuilliers >> >> >> I couldn't use the display name or the getattr failed. >> >> > ??? >> >> When I first did: >> >> extra(select={"Delta" : self.field_name}) >> >> Then getattr(self.field_name) failed with "object has no attribute >> 'col1-col2'". > > Obviously - the attribute name is then "Delta", not self.field_name > (which is rather a misleading name since it's really an sql clause, > not a field name).
Like I said in my original post, I didn't write this app. I'm new at this client, and I'm just tweaking it. It is a field on the screen that the user can select (from a list of data base columns), and that's how it get passed into the python code (as field_name). >> Yes, I've been writing python for years too, > > Sorry, that's not always the case for peoples posting here. NP. There's always more to learn. >> and I realize I can put >> in a dict. But it still has to be in 2 places - the code that >> implements the first query that generates the chart, and the code that >> does the drill down query when they click on a point. > > You can eventually define the dict in one place and use it from both, > but once again it's hard to say without seeing the real code :-| The way this app is structured, they are 2 different classes. I could put the mapping in a database table, or create a method in the database object's class (i.e. the table that both use) that has the dict and provides the mapping. Yeah, that's the ticket! Thanks for getting my brain going. -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.