我在尝试打开 Django Rest 框架的 url 时遇到错误。 它在本地运行良好,但是当我将它部署到服务器时,出现以下错误。在服务器上我有 django 1.9。
Exception Value:
'url' is not a valid tag or filter in tag library 'future'
Exception Location: /home/maxo/django-trunk/django/template/base.py in parse, line 506
Error during template rendering
In template /usr/local/lib/python2.7/dist-packages/rest_framework/templates/rest_framework/base.html, error at line 1
'url' is not a valid tag or filter in tag library 'future'
1
{% load url from future %}
2 {% load staticfiles %}
3 {% load rest_framework %}
4 <!DOCTYPE html>
5 <html>
6 <head>
7 {% block head %}
8
9 {% block meta %}
10 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
11 <meta name="robots" content="NONE,NOARCHIVE" />
注意:当我删除以下行时: {% load url from future %} from base.html 它现在工作正常,但是 rest api 的风格消失了。有没有其他替代方法来替换 {% load url from future %}?
最佳答案
在 Django 1.9 中,url
模板标签已从 future
模板标签库中移除。
ssi
andurl
template tags will be removed from thefuture
template tag library (used during the 1.3/1.4 deprecation period).
因此,现在您无法从 Django 1.9 中的 future
库加载 url
标记。您可以改用内置的 url
标记。
{% url 'some-url-name' %}
关于python - 部署了 rest-framework 的 django 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31624606/