3

I am having error when trying to open url of Django Rest framework. It was working fine locally, but when I deployed it on server, I am having following error. On 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/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" />

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

1
  • When I removed following line: {% load url from future %} from base.html Its working fine now, but then style of rest api is gone. Is there any other alternative to replace {% load url from future %}? Commented Jul 25, 2015 at 8:57

2 Answers 2

4

In Django 1.9, url template tag was removed from the future template tag library.

From Django 1.9 release notes:

ssi and url template tags will be removed from the future template tag library (used during the 1.3/1.4 deprecation period).

So, now you can't load the url tag from the future library in Django 1.9. You can use the built-in url tag instead.

{% url 'some-url-name' %}
Sign up to request clarification or add additional context in comments.

4 Comments

When I removed following line: {% load url from future %} from base.html Its working fine now, but then style of rest api is gone. Is there any other alternative to replace {% load url from future %}?
You can use the default url tag instead. {% url 'some-url-name' %}
so do I need replace 'some-url-name' with anything? as I need to replace {% load url from future %} with something on base.html file which is in DJANGO rest Framwork folder
some-url-name can be a view function or a reverse url name. Lets say if your url has a name=my_url_name argument defined in the urls.py file, then you can just use{% url 'my_url_name' %}. In case of namespaced URL, you need to specify the fully qualified URL like {% url 'myapp:view_name' %}
1

you can fix that by installing a newer version of djangorestframework

pip install 'djangorestframework>=3.2.3'

i don't think it's a good idea to develop on a version of django and deploy on some other version, that'll most likely give you problems. i'd work using virtualenv, and saving a requirements.txt file with the version of all the packages you're using. that way when you deploy you can run:

pip install -r requirements.txt

and that'll install the same versions as you are using in your dev environment.

hope this helps. salú

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.