On Wed, Sep 23, 2009 at 1:05 PM, Chris Withers <ch...@simplistix.co.uk>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', > extra_context=dict( > column_titles = [f.name for f in model._meta.fields], > ) > ) > > Where index.html is: > > <table> > <tr> > {% for title in column_titles %} > <th>{{title}}</th> > {% endfor %} > </tr> > {% for object in object_list %} > <tr> > {% for name in column_titles %} > <td> > {{*what goes here*}} > </td> > {% endfor %} > </tr> > {% endfor %} > </table> > > What do I put in the marked spot to be the equivalent of > getattr(object,name)? > > Using something like this: http://www.djangosnippets.org/snippets/38/ (with the change noted in the comment): {{ object|gettattr:name }} Karen --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---