I suddenly get a strange error in code that previously worked. I recently upgraded to Django 1.9.6 from version 1.9.4.
In one of my views, I have:
from django.contrib import messages from django.utils.translation import ugettext_lazy as _ messages.success(request, str( _('A string with a ') + '<a target="_blank" href="/preview/' + mymodel.hash + '">' + _('link!') + '</a>.'), extra_tags="safehtml" )
Now this gives a TypeError on the second last line:
Can't convert '__proxy__' object to str implicitly
Why? How to fix it?
Edit:
This can be fixed by transferring the second call to ugettext_lazy() to str() (i.e. the code becomes str( _('link!') ) . This allows the presentation to be rendered perfectly. Now my questions are: Why? The whole composite line is already wrapped in str() , and as I said, this code worked fine with the previous version of django. Is this a bug?
source share