I'm using djangio-localeurl to provide locale switching based on my URLs. It works fine pretty much apart from a little hiccup.
In some of my class-based views, I have been using a lazy reverse function else I get errors about missing URL patterns. This was something due to the order in which files were imported. One explanation read:
Since the decorators of your views are evaluated during parsing urls.py you have an 'chicken - egg' problem. The method reverse() can't be used since urls.py is not read.
It seems that django-localeurl monkey-patches Django's internal reverse
function. This change works fine but my lazy_reverse
function gives me issues. Now when I run my tests, I get errors at the places where I've used this lazy_reverse
function. Here's my lazy_reverse
function code:
from django.utils.functional import lazy
from django.core import urlresolvers
reverse_lazy = lambda name=None, *args : lazy(urlresolvers.reverse, str)(name, args=args)
The error I keep getting is:
TypeError: Lazy object returned unexpected type.
I can seem to understand what is causing this. This issue seems to disappear the moment I remove localeurl
from my INSTALLED_APPS
setting.
Any ideas on how to resolve this?
Thanks