Django pass object to include

前端 未结 1 1584
谎友^
谎友^ 2020-12-23 11:48

I cannot do the following in Django:

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

or



        
相关标签:
1条回答
  • 2020-12-23 12:17

    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.

    0 讨论(0)
提交回复
热议问题