I have a base.html in my_project/jinja2/ and it contains everything except the <body> for a site. We then extend base.html as one does.
In this example I am extending base.html from app people in a file at my_project/people/jinja2/people/people_list.html using something like this:
{% extends "base.html" %}
{% block content %}
<!-- Some html -->
{% endblock content %}
My base.html includes a link to the blog rss feed in the <head> like so:
<link rel="alternate" type="application/atom+xml" title="Blog" href="{{ url('blog:articles_feed') }}" />
This works fine most places such as my_project/jinja2/index.html and my_project/jinja2/blog_list.html but in this 3rd app people, I am getting the following error at this same line of template code:
AttributeError: 'str' object has no attribute '__call__'
Since jinja2 has better debugging I can run python in werkzueg and see some potential details of what might be happening:
locals()
which outputs:
{
'_': {...},
'static': < bound method StaticFilesStorage.url of < django.contrib.staticfiles.storage.StaticFilesStorage object at 0x7f423ec3ebe0 >> ,
'joiner': < class 'jinja2.utils.Joiner' > ,
'request': < WSGIRequest: GET '/case-studies/hog?__debugger__=yes&cmd=locals()&frm=139922493301984&s=XfAagGnpxRWFBRRd0Uzk' > ,
'page': None,
'csrf_input': < django.utils.functional.lazy. < locals > .__proxy__ object at 0x7f423e8262e8 > ,
'cycler': < class 'jinja2.utils.Cycler' > ,
'dict': < class 'dict' > ,
'absolute_url': < function absolute_url at 0x7f423ece5b70 > ,
'lipsum': < function generate_lorem_ipsum at 0x7f423ebfc8c8 > ,
'view': < leaf.views.LeafTemplateView object at 0x7f423e820198 > ,
'range': < class 'range' > ,
'ngettext': < function ungettext at 0x7f42450547b8 > ,
'gettext': < function ugettext at 0x7f4245054730 > ,
'absolute_root': < function absolute_root at 0x7f423ece8268 > ,
'datetime': < class 'datetime.datetime' > ,
'csrf_token': < django.utils.functional.lazy. < locals > .__proxy__ object at 0x7f423e826400 > ,
'url': 'people/all'
}
I'm not sure if this is a correct assumption, but is url not being correctly added to the environment as a function, but a string instead? It's in my jinja2.py file, and works elsewhere as expected in jinja2 templates. What gives?
urlin yourpeopleview.peopleapp with a url route like:url(r'^people-list/', TemplateView.as_view(template_name="people_list.html")),. From Django source for TemplateView, I don't seeTemplateViewadding aurlcontext variable. Using jinja, would anything else be adding context unexpectedly for just this view (it works fine in some other views).