Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django pass object to include

I cannot do the following in Django:

{% include "admin/includes/pager.html" with title_pager="{{myobject.title}}" %}

or

{% include "admin/includes/pager.html" with title_pager="{{myobject}}" %}

What is the workaround?

like image 231
gpasse Avatar asked Oct 28 '11 11:10

gpasse


1 Answers

You do not need to surround arguments in {{ }} brackets in template tags.

If it's a variable, not a string, then do not use "" quotes.

The following should work:

{% include "admin/includes/pager.html" with title_pager=myobject.title %}

{% include "admin/includes/pager.html" with title_pager=myobject %}

See the Django docs for the include tag for more information.

like image 120
Alasdair Avatar answered Sep 28 '22 12:09

Alasdair