On Wed, Apr 07, 2021 at 11:02:04AM -0700, sebasti...@gmail.com wrote:
> i want to create a Listview like this:
> 
> class HistorieListView(ListView):
>     model = Address
>     template_name = 'marketing/liststandardtemplate.html'
>     fieldlist = ('id', 'lastname', 'firstname')
> 
> now i want in liststandardtemplate.html that i iterate in tablebody over 
> fieldlist:
> 
> <tbody>
>                             {%for element in object_list%}
>                             <tr>
>                                {% for field in fieldlist %}
>                                 <td>
>                                 {{ element.field }}
>                                 </td>
>                                {% endfor %}
>                             </tr>
>                             {% endfor %}
>                             </tbody>
> 
> but   {{ element.field }} won't work. This is absolut clear why but i have 
> no idea how i can create such a template....

You'll probably need to perform a getattr lookup in your template here.
Found this little solution on the ole' stackoverflow:

https://stackoverflow.com/a/1112236/226697

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20210408214658.GM15054%40fattuba.com.

Reply via email to