Error while deploying django with rest-framework

I am getting an error when I try to open the URL of the Django Rest framework. It worked fine locally, but when I deployed it to the server, I got an error. On the server, I have 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/ 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'

      {% load url from future %}

2   {% load staticfiles %}
3   {% load rest_framework %}
4   <!DOCTYPE html>
5   <html>
6       <head>
7           {% block head %}
9               {% block meta %}
10                  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
11                  <meta name="robots" content="NONE,NOARCHIVE" />


NOTE. When I removed the following line: {% load url from future%} from base.html Now it works fine, but then the rest api style is gone. Is there any other alternative to replace {% load url from future%}?


source to share

2 answers

In Django 1.9, the template tag has url

been removed from the tag library future


From the Django 1.9 release note :



and url

will be removed from the future

library tag (used in the 1.3 / 1.4 grace period).

So now you cannot load a tag url

from a library future

in Django 1.9. You can use a tag instead url


{% url 'some-url-name' %}




you can fix it by installing a newer version of djangorestframework

pip install 'djangorestframework>=3.2.3'


I don't think it is a good idea to develop on a django version and deploy to some other version, which will most likely give you problems. I would use virtualenv and keep a file requirements.txt

with the version of all packages you are using. So, when deploying, you can run:

pip install -r requirements.txt


and it will install the same versions as in your development environment.

hope this helps. SALU



All Articles