2012-04-13 66 views
0

这是我以前的帖子。 Template includes and django views/urls. How (do/should) they work?带模板包含标签的TemplateSyntaxError和SyntaxErrors

再次,迷你盒工作正常。我已经听取了建议并试图与之合作。

所以我有一个profile(request, profile_type, username)视图。我试图从中获取'profile_intros'context并将其放入包含的mini_profile.html模板中。

我试图做一个包含标签(我将整个网站的其他地方需要它):

@register.inclusion_tag('includes/profile_info.html', takes_context=True)(profile_info) 
    def profile_info(context): 
     profile_intros = FundRecommendation.objects.filter(investor=profile).count() 
     return{ 
      'profile_intros' : context['profile_intros'], 
     } 

和投掷{% profile_info %}到包括mini_profile.html模板。我遵循了django doc示例,我真的不知道我做错了什么。

我越来越:

Exception Type:  TemplateSyntaxError 
Exception Value: Invalid block tag: 'profile_info' 

回答

0

你忘了使用{% load ... %}加载模板标签库。

+0

我试过了,还在我安装的应用程序中添加了'django.contrib.profile_info'。由于我的控制台中有'Error:No module named profile_info',我无法启动我的服务器或syndb。 :\ – Modelesq 2012-04-13 20:00:26

+0

为什么你认为“django.contrib.profile_info”是要添加的正确值? – 2012-04-13 20:02:36

+0

例子。我是一个n00b(充其量),我只是想玩弄它。我所有的应用程序已经在那里,我不太清楚还有什么要补充说实话的。 – Modelesq 2012-04-13 20:07:08