# Buggy code
def show_component(request, project, component):
    obj = get_component(request, project, component)
    user = request.user

    last_changes = Change.objects.prefetch().order().filter(component=obj)[:10]

    return render(
        request,
        "component.html",
        {
            "allow_index": True,
            "object": obj,
            "project": obj.project,
            "translations": sort_objects(prefetch_stats(obj.translation_set.all())),
            "show_language": 1,
            "reports_form": ReportsForm(),
            "last_changes": last_changes,
            "last_changes_url": urlencode(
                {"component": obj.slug, "project": obj.project.slug}
            ),
            "language_count": Language.objects.filter(translation__component=obj)
            .distinct()
            .count(),
            "replace_form": optional_form(ReplaceForm, user, "unit.edit", obj),
            "bulk_state_form": optional_form(
                BulkStateForm, user, "translation.auto", obj, user=user, obj=obj
            ),
            "whiteboard_form": optional_form(
                WhiteboardForm, user, "component.edit", obj
            ),
            "delete_form": optional_form(
                DeleteForm, user, "component.edit", obj, obj=obj
            ),
            "rename_form": optional_form(
                ComponentRenameForm,
                user,
                "component.edit",
                obj,
                request=request,
                instance=obj,
            ),
            "move_form": optional_form(
                ComponentMoveForm,
                user,
                "component.edit",
                obj,
                request=request,
                instance=obj,
            ),
            "search_form": SearchForm(),
            "alerts": obj.alert_set.order_by("name"),
        },
    )


# Traceback (TypeError)
weblate@jb9:~$ ./venv/bin/weblate list_versions
* Weblate 3.6.1
* Python 3.5.3
* Django 2.2.1
* Celery 4.3.0
* celery-batches 0.2
* six 1.12.0
* social-auth-core 3.2.0
* social-auth-app-django 3.1.0
* django-appconf 1.0.3
* translate-toolkit 2.3.1
* translation-finder 1.5
* Whoosh 2.7.4
* defusedxml 0.6.0
* Git 2.11.0
* Pillow 6.0.0
* python-dateutil 2.8.0
* lxml 4.3.3
* django-crispy-forms 1.7.2
* django_compressor 2.2
* djangorestframework 3.9.4
* user-agents 2.0
* jellyfish 0.7.1
* diff-match-patch 20121119
* pytz 2019.1
* pyuca 1.2
* python-bidi 0.4.0
* PyYAML 5.1
* hub 2.3.0-pre10
* Database backends: django.db.backends.postgresql_psycopg2
* Cache backends: avatar:FileBasedCache, default:RedisCache
* Celery: redis://127.0.0.1:6379/3, redis://127.0.0.1:6379/3, regular
* Platform: Linux 4.9.0-9-amd64 (x86_64)
Exception ignored in: <function WeakValueDictionary.__init__.<locals>.remove at 0x7f0db6159950>
Traceback (most recent call last):
File "/var/www/weblate/venv/lib/python3.5/weakref.py", line 117, in remove
TypeError: 'NoneType' object is not callable
Exception ignored in: <function WeakValueDictionary.__init__.<locals>.remove at 0x7f0db6159950>
Traceback (most recent call last):
File "/var/www/weblate/venv/lib/python3.5/weakref.py", line 117, in remove
TypeError: 'NoneType' object is not callable

# Fixed code
def show_component(request, project, component):
    obj = get_component(request, project, component)
    user = request.user

    last_changes = Change.objects.prefetch().order().filter(component=obj)[:10]

    return render(
        request,
        "component.html",
        {
            "allow_index": True,
            "object": obj,
            "project": obj.project,
            "translations": sort_objects(
                prefetch_stats(obj.translation_set.prefetch())
            ),
            "show_language": 1,
            "reports_form": ReportsForm(),
            "last_changes": last_changes,
            "last_changes_url": urlencode(
                {"component": obj.slug, "project": obj.project.slug}
            ),
            "language_count": Language.objects.filter(translation__component=obj)
            .distinct()
            .count(),
            "replace_form": optional_form(ReplaceForm, user, "unit.edit", obj),
            "bulk_state_form": optional_form(
                BulkStateForm, user, "translation.auto", obj, user=user, obj=obj
            ),
            "whiteboard_form": optional_form(
                WhiteboardForm, user, "component.edit", obj
            ),
            "delete_form": optional_form(
                DeleteForm, user, "component.edit", obj, obj=obj
            ),
            "rename_form": optional_form(
                ComponentRenameForm,
                user,
                "component.edit",
                obj,
                request=request,
                instance=obj,
            ),
            "move_form": optional_form(
                ComponentMoveForm,
                user,
                "component.edit",
                obj,
                request=request,
                instance=obj,
            ),
            "search_form": SearchForm(),
            "alerts": obj.alert_set.order_by("name"),
        },
    )