Re: equivalent of getattr in a django template

2009-09-23 Thread Chris Withers
Daniel Roseman wrote: > It's an intentional limitation of the template language that you can't > do that. You'll need to write a custom tag or filter - luckily it can > be done very trivially as a filter: > > @register.filter > def get_attr(obj, val) > return getattr(obj, val) > > Now in the

Re: equivalent of getattr in a django template

2009-09-23 Thread Karen Tracey
On Wed, Sep 23, 2009 at 1:05 PM, Chris Withers wrote: > > Hi All, > > I have this view function: > > def index(request,model,pk=None): > > return list_detail.object_list( > request, > queryset=model.objects.all(), > paginate_by=10, > template_name='index.html',

Re: equivalent of getattr in a django template

2009-09-23 Thread Daniel Roseman
On Sep 23, 6:05 pm, Chris Withers wrote: > Hi All, > > I have this view function: > > def index(request,model,pk=None): > >      return list_detail.object_list( >          request, >          queryset=model.objects.all(), >          paginate_by=10, >          template_name='index.html', >        

Re: equivalent of getattr in a django template

2009-09-23 Thread Chris Withers
Maksymus007 wrote: > {{object.name}} ? no, that is the equivalent of: getattr(object,'name') I want: getattr(object,name) Subtle, but rather important, difference... Chris -- Simplistix - Content Management, Batch Processing & Python Consulting - http://www.simplistix.co.uk -

Re: equivalent of getattr in a django template

2009-09-23 Thread Maksymus007
On Wed, Sep 23, 2009 at 7:05 PM, Chris Withers wrote: > > Hi All, > > I have this view function: > > def index(request,model,pk=None): > >     return list_detail.object_list( >         request, >         queryset=model.objects.all(), >         paginate_by=10, >         template_name='index.html',

equivalent of getattr in a django template

2009-09-23 Thread Chris Withers
Hi All, I have this view function: def index(request,model,pk=None): return list_detail.object_list( request, queryset=model.objects.all(), paginate_by=10, template_name='index.html', extra_context=dict( column_titles = [f.name for