TemplateSyntaxError at /

246 views
Skip to first unread message

Malik Rumi

unread,
Jul 9, 2016, 9:38:06 PM7/9/16
to Django users

Invalid template name in 'extends' tag: ''. Got this from the 'baseX.html' variable.

The first line in index.html is:
{% extends baseX.html %}



I got this error when trying out a new template package I bought. I thought it was telling me something was wrong with the name of the base template being extended, but changing the name numerous times always brings the same error.

I tried using a functional view instead, but I still got the same error.

Debug Toolbar says:

        Templates

index.html
    /home/malikarumi/Projects/cannon/jamf/static/index.html
    ▶ Toggle context
None
    <unknown source>
   
That's when I figured out that the error was with baseX itself. The traceback points to line 141 in loader_tags.py, which is the get_parent function:


    def get_parent(self, context):
        parent
= self.parent_name.resolve(context)
       
if not parent:
            error_msg
= "Invalid template name in 'extends' tag: %r." % parent
           
if self.parent_name.filters or\
                    isinstance
(self.parent_name.var, Variable):
                error_msg
+= " Got this from the '%s' variable." %\
                   
self.parent_name.token
           
raise TemplateSyntaxError(error_msg)
       
if isinstance(parent, Template):
           
# parent is a django.template.Template
           
return parent
       
if isinstance(getattr(parent, 'template', None), Template):
           
# parent is a django.template.backends.django.Template
           
return parent.template
       
return self.find_template(parent, context)


       
Both baseX and index are in the same folder. Somehow Django has decided my baseX is not a django.template.django.Template. I don't know what makes a template qualify as a django.Template, and wasn't able to find anything on that. baseX is a pre-made template I liked and bought online. The designer doesn't know anything about Django. As far as I can tell, it is just html, css, and javascript, like any other template. It is bootstrap, just like the template I was using before. I have searched around, there's lots of stuff about templates in general, but I haven't found anything on this particular issue.

I did come across django-bootstrap3, but I see no reason why that's required to use bootstrap. I didn't have it with the previous bootstrap theme I was using and that worked.

Your insights appreciated.
ubuntu 15.10, Python 2.7.10, Django 1.9.1, Bootstrap 3.3.6

James Schneider

unread,
Jul 9, 2016, 9:45:43 PM7/9/16
to django...@googlegroups.com


On Jul 9, 2016 6:38 PM, "Malik Rumi" <malik....@gmail.com> wrote:
>
>
> Invalid template name in 'extends' tag: ''. Got this from the 'baseX.html' variable.
>
> The first line in index.html is:
> {% extends baseX.html %}
>

Try adding quotes around "baseX.html", your referring to it as a variable, not as the name of the template.

-James

Malik Rumi

unread,
Jul 9, 2016, 10:46:32 PM7/9/16
to django...@googlegroups.com
God damn. That was it - something silly and obvious, but only to a fresh set of eyes. Thank you!

--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/Wm5gJTbSD8Q/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2Be%2BciXZHCechLYWnP8ewkr9H%3D0asJne7KRMQjH1OsvXyYUgPQ%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.



--

"Every time you see a black kid wearing a hoodie, you say: There's a thug. If you see a white kid wearing hoodie, you say: There's Mark Zuckerberg," Jones told USA TODAY last year.

"I said, 'That's because of racism. And Prince said, 'Maybe so, or maybe you civil rights guys haven't created enough Mark Zuckerbergs.' " 

Reply all
Reply to author
Forward
0 new messages