Here again I am trying to upgrade my application from Django1.5 to Django1.6 which I documented here.
The bump I found in my code was the url import in urls.py
Before we import urls like this :
from django.conf.urls.defaults import *
In Django1.5 there was warning that this will be deprecated. Now in Django1.6 , the app wont start.
Instead we must use this for the import :
from django.conf.urls import *
The package moved to other place. This was a bit wow for a big applications where the urls.py spread all over the application.
For backward compatibility I use this import :
try: from django.conf.urls.defaults import * except: from django.conf.urls import *
Then the other bump was the cache_page decorator. In Django 1.3 the usage was :
from django.views.decorators.cache import cache_page urlpatterns = ('', (r'^foo/(\d{1,2})/$', cache_page(my_view, 60 * 15)), )
In Django 1.4 the usage was :
from django.views.decorators.cache import cache_page urlpatterns = ('', (r'^foo/(\d{1,2})/$', cache_page(60 * 15)(my_view)), )
when in Django1.5 there were deprecated warning for the cache decorator. It said :
The cache_page decorator must be called like: cache_page(timeout, [cache=cache name], [key_prefix= key prefix])
And in Django1.6 there error came out in using cache decorator. How I use the cache decorator was :
url(r'^sitemap\.xml$', cache_page(sitemap,LONG_CACHE), {'sitemaps': sitemaps}),
So to fix it, we need to change the calling of cache_page decorator. We call using the cache_page(timeout, viewfunc) so here are the fixed url :
url(r'^sitemap\.xml$', cache_page(LONG_CACHE)(sitemap), {'sitemaps': sitemaps}),
With this all working in my application.One thing which i concert is that johnnycache not working in Django1.6 which needed for cache all database query.
The most version updated version i use now will be Django 1.6.2 as per today 9 March 2014.
Hope this give hint for you who need upgrading also.
1 comments:
I'm currently in the midst of a 1.4 -> 1.7 update and have run into similar gotchas. Thanks for the posts about this. They've been great confirmation that I'm doing the correct things. :)
One thing you should be aware of with this kind of update (especially to 1.4 -> 1.7) is the addition of the UserProfile -> AbstractUser and South -> Django Migrations - with both happening simultaneously. That has proven to be a bit tricky.
Post a Comment