# Buggy code
def generate_stats(self, request, response):
    self.record_stats(
        {
            "get": [(k, request.GET.getlist(k)) for k in sorted(request.GET)],
            "post": [(k, request.POST.getlist(k)) for k in sorted(request.POST)],
            "cookies": [(k, request.COOKIES.get(k)) for k in sorted(request.COOKIES)],
        }
    )
    view_info = {
        "view_func": _("<no view>"),
        "view_args": "None",
        "view_kwargs": "None",
        "view_urlname": "None",
    }
    try:
        match = resolve(request.path)
        func, args, kwargs = match
        view_info["view_func"] = get_name_from_obj(func)
        view_info["view_args"] = args
        view_info["view_kwargs"] = kwargs
        view_info["view_urlname"] = getattr(match, "url_name", _("<unavailable>"))
    except Http404:
        pass
    self.record_stats(view_info)

    if hasattr(request, "session"):
        self.record_stats(
            {
                "session": [
                    (k, request.session.get(k)) for k in sorted(request.session.keys())
                ]
            }
        )


# Traceback (AttributeError)
Traceback (most recent call last):
File "/home/folt/env_work/temes-Yu7Jpmcx-py3.7/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/home/folt/env_work/temes-Yu7Jpmcx-py3.7/lib/python3.7/site-packages/sentry_sdk/integrations/django/middleware.py", line 134, in call
return f(*args, **kwargs)
File "/home/folt/env_work/temes-Yu7Jpmcx-py3.7/lib/python3.7/site-packages/sentry_sdk/integrations/django/middleware.py", line 90, in sentry_wrapped_method
return old_method(*args, **kwargs)
File "/home/folt/env_work/temes-Yu7Jpmcx-py3.7/lib/python3.7/site-packages/debug_toolbar/middleware.py", line 67, in call
panel.generate_stats(request, response)
File "/home/folt/env_work/temes-Yu7Jpmcx-py3.7/lib/python3.7/site-packages/debug_toolbar/panels/request.py", line 30, in generate_stats
"post": [(k, request.POST.getlist(k)) for k in sorted(request.POST)],
File "/home/folt/env_work/temes-Yu7Jpmcx-py3.7/lib/python3.7/site-packages/debug_toolbar/panels/request.py", line 30, in <listcomp>
"post": [(k, request.POST.getlist(k)) for k in sorted(request.POST)],
AttributeError: 'dict' object has no attribute 'getlist'

# Fixed code
def generate_stats(self, request, response):
    self.record_stats(
        {
            "get": [(k, request.GET.get(k)) for k in sorted(request.GET)],
            "post": [(k, request.POST.get(k)) for k in sorted(request.POST)],
            "cookies": [(k, request.COOKIES.get(k)) for k in sorted(request.COOKIES)],
        }
    )
    view_info = {
        "view_func": _("<no view>"),
        "view_args": "None",
        "view_kwargs": "None",
        "view_urlname": "None",
    }
    try:
        match = resolve(request.path)
        func, args, kwargs = match
        view_info["view_func"] = get_name_from_obj(func)
        view_info["view_args"] = args
        view_info["view_kwargs"] = kwargs
        view_info["view_urlname"] = getattr(match, "url_name", _("<unavailable>"))
    except Http404:
        pass
    self.record_stats(view_info)

    if hasattr(request, "session"):
        self.record_stats(
            {
                "session": [
                    (k, request.session.get(k)) for k in sorted(request.session.keys())
                ]
            }
        )