开发者

passing variable to django custom template tag

开发者 https://www.devze.com 2023-01-31 13:33 出处:网络
Im using django-profiles. In my profile_detail template I know that I will receive a profile variable.

Im using django-profiles. In my profile_detail template I know that I will receive a profile variable.

I want to make a custom tag that gets the content per user via user id. Like this:

{% get_user_content book.review profile.user.id as review_list %}

However, when my pars开发者_StackOverflow中文版er runs It seems like profile.user.id was not transformed to an id number and throws an exception.

I can verify that my custom tag works by changing profile.user.id to say 1 for admin.

{% get_user_content book.review 1 as review_list %}

Has anyone deals with it before? What did you do?


Template tags never translate arguments. You need to do the lookup in the context yourself.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号