Tuesday, August 13, 2013

AttributeError: '__proxy__' object has no attribute 'decode'

Hi Folks,

    I implemented one independent django app with python 2.7. I ported it to python 3 from python 2.7 using 2to3 module. I created egg of this app using setuptools and using it in another django project with version 1.5.1 of django.
    Some of my view functions are using HttpResponseRedirect with reverse_lazy as first argument where reverse_lazy takes named_url as first argument. These functions was working fine before porting with django 1.4.3 and python 2.7 but now I am getting AttributeError after porting to python 3.

My view function is :

    HOME_URL = reverse_lazy('auth_home')
       def logout_user(request):
        """
        Logs-out the user and redirects to login page.
        """
        logout(request)
        return HttpResponseRedirect(HOME_URL)


The error which I gets when I tries to access this view function is:


    File "env/lib/python3.2/site-packages/TestProject-0.2-py3.2.egg/auth/views.py", line 123, in login_user
        return HttpResponseRedirect(HOME_URL)
    File env/lib/python3.2/site-packages/django/http/response.py", line 388, in __init__
        parsed = urlparse(redirect_to)
    File "lib/python3.2/urllib/parse.py", line 292, in urlparse
        url, scheme, _coerce_result = _coerce_args(url, scheme)
    File "lib/python3.2/urllib/parse.py", line 112, in _coerce_args
        return _decode_args(args) + (_encode_result,)
    File "lib/python3.2/urllib/parse.py", line 96, in _decode_args
        return tuple(x.decode(encoding, errors) if x else '' for x in args)
    File "lib/python3.2/urllib/parse.py", line 96, in <genexpr>
        return tuple(x.decode(encoding, errors) if x else '' for x in args)
    AttributeError: '__proxy__' object has no attribute 'decode'


Any help will be highly appreciated.


Thanks and regards.
Abhijeet Shete


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment