Django1.7升级到Django1.9一些点

1、在urls.py里,不要直接用字符串来描述方法、要用引用来配置(越来越向OOP看齐?),比如,再这么配置的话,

 url(r'^$', 'portal.views.index', {'template_name': 'index.html'}, name='index'),

会得到一个警告:

RemovedInDjango110Warning: Support for string view arguments to url() is deprecated and will be removed in Django 1.10 (got portal.views.index). Pass the callable instead.
  url(r'^$', 'portal.views.index', {'template_name': 'index.html'}, name='index'),

应该改为:

from portal.views import index
...
url(r'^$', index, {'template_name': 'index.html'}, name='index'),
...

2、render_to_response的这种形式也会得到过时的警告:

return render_to_response(template_name,
                              template_var,
                              context_instance=RequestContext(request))

应该改为:

from django.shortcuts import render
...
from django.shortcuts import render
...
return render(request, template_name, template_var)

回头再添加。。。

小白 :
意外发现,前来学习
老楠 Reply to 小白 :
共同学习。
For example, "name@something.com". If someone replies to you it will be via email.
For example, "http://someaddress.com"