开发者

Django Templates extends tag problem

I am using {% extends "base.html" %}

I get the following error

must 开发者_JAVA技巧be the first tag in the template.

Can any one please help


place {% extends "base.html" %} in line 1 of your editor. Literally put it in line 1. REMOVE all comments at the top if you have any..


It must be the very first django template tag in your template.

Documentation says:

If you use {% extends %} in a template, it must be the first template tag in that template. Template inheritance won't work, otherwise.

Documentation can be found here


I also got into that problem. I was using comment as the first tag it wasn't working.After I removed that it worked. Used this: {% comment %} inheriting the base html {% endcomment %}

To describe what I was doing.Got error. Removed this and used extend as the first template tag.Worked!!!!


Always remember to mention the {% extends '<TEMPLATE_NAME>' %} in the first line itself, don't even try to put comments on the first line. This will surely resolve the error!

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜