I have a Django app that continues to be fussy about the {% url ... %}
templating tag. I've fixed this before, but it now it's giving me a SyntaxError
on loading the template.
Start with the relevant template lines:
<a href="{% url 'project-index' %}">
<img src="{{ STATIC_URL }}images/logo.png" alt="Logo">
</a>
Function I'm trying to reverse()
to in views.py
:
def index (request):
return render(request, "project/index.html", { "user" : request.user })
Url patterns ( urls.py
):
urlpatterns = patterns("project.views",
url(r'^$', "index", name="project-index"),
url(r'^login/?$', "login", name="project-login"),
url(r'^logout/?$', "logout", name="project-logout"),
)
Main app included urls ( urls.py
):
urlpatterns = patterns('',
url('', include('project.urls')),
)
Here is a gist of the traceback .
The traceback doesn't show the exact line number for the template error, so here's what it gives me:
Error during template rendering
In template /Users/josh/Dropbox/Projects/app/sc/templates/layouts/base.html, error at line 47
The "old" url tag doesn't accept quotes but this will be deprecated. Use {% load url from future %}
in Django <1.5. Check the Forwards compatibility section in documentation https://docs.djangoproject.com/en/1.4/ref/templates/builtins/#url
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.