开发者

passing variable to django custom template tag

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜