Git Product home page Git Product logo

Comments (14)

kmike avatar kmike commented on August 19, 2024

There is a test case in my branch.

from django-debug-toolbar.

newmaniese avatar newmaniese commented on August 19, 2024

Wow, this bug is nasty. Took me days to figure out.

Breaking this down, something along these lines on line 32 is a little ugly but certainly works.

        for k,v in self.view_kwargs.iteritems():
                    new_view_kwargs[str(k)] = str(v)

use the new_views_kwargs in the context

from django-debug-toolbar.

bjunix avatar bjunix commented on August 19, 2024

Just wanted to let you know that I stumbled upon the same problem. I passing a custom form to a view via urls.py.

I do not quite get this as it only occurs in the staging/testing enviroment (nginx with apache) not durring dev (local runserver).

Is there something I can do to help?

from django-debug-toolbar.

nickers avatar nickers commented on August 19, 2024

Ok, I am new in python,django & rosette stuff, but shouldn't it all be like that:

context['session'] = [(unicode(k), unicode(self.request.session.get(k))) for k in self.request.session.iterkeys()]

Then it would work with any encoding?

from django-debug-toolbar.

kevinpostal avatar kevinpostal commented on August 19, 2024

getting same error... Any fix?

from django-debug-toolbar.

fed239 avatar fed239 commented on August 19, 2024

Isn't the problem fixed? I've installed it using pip.

from django-debug-toolbar.

 avatar commented on August 19, 2024

The following code in request_vars.py fixes this issue:

def content(self): view_func = self.view_func if not hasattr(self.view_func, '**name**'): view_func = self.view_func.**class**
    context = self.context.copy()
    context.update({
        'get': [(k, self.request.GET.getlist(k)) for k in self.request.GET],
        'post': [(k, self.request.POST.getlist(k)) for k in self.request.POST],
        'cookies': [(k, self.request.COOKIES.get(k)) for k in self.request.COOKIES],
        'view_func': '%s.%s' % (view_func.__module__, view_func.__name__),
        'view_args': self.view_args,
        'view_kwargs': self.view_kwargs
    })
    if hasattr(self.request, 'session'):
        context.update({
            'session': [(k, self.request.session.get(k)) for k in self.request.session.iterkeys()]
        })

    return render_to_string('debug_toolbar/panels/request_vars.html', context)

from django-debug-toolbar.

torhve avatar torhve commented on August 19, 2024

jbeaurain's code doesn't fix it for me. However nickers' code does.

from django-debug-toolbar.

saevarom avatar saevarom commented on August 19, 2024

No activity in 2 years, is this still a problem?

from django-debug-toolbar.

aaugustin avatar aaugustin commented on August 19, 2024

I spend a few minutes attempting to reproduce this and didn't succeed. @kmike could you check if the issue still exists in master?

from django-debug-toolbar.

kmike avatar kmike commented on August 19, 2024

@aaugustin sorry, i'm taking a break from web development and checking if this issue exists in master will require me setting up a django project, figuring out again what was my issue, etc. Wow, this ticket is 4 years old - I didn't realize I'm using Python for so long :) The mentioned test case for reproducing this issue is here: kmike@69dfed1

from django-debug-toolbar.

aaugustin avatar aaugustin commented on August 19, 2024

Never mind, I was just asking in case it was faster for you than for me to reproduce.

from django-debug-toolbar.

aaugustin avatar aaugustin commented on August 19, 2024

Your test case passes on master.

For bonus points I'm going to commit the test case with an object whose repr contains non-ASCII characters rather than the Django Form class, but I confirmed the test passes with Form too.

from django-debug-toolbar.

aaugustin avatar aaugustin commented on August 19, 2024

Just to be clear, the test validates that this object doesn't crash the request vars panel:

>>> from tests.models import NonAsciiRepr
>>> unicode(NonAsciiRepr())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1: ordinal not in range(128)
>>> str(NonAsciiRepr())
'n\xc3\xb4t \xc3\xa5sc\xc3\xad\xc3\xac'
>>> NonAsciiRepr()
nôt åscíì

from django-debug-toolbar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.