Skip to content

[BUG] BaseBreadcrumbMixin does not work with View class #801

@TeaDrinkingProgrammer

Description

@TeaDrinkingProgrammer

Is there an existing issue for this?

  • I have searched the existing issues

Does this issue exist in the latest version?

  • I'm using the latest release

Describe the bug?

In the docs, there is an example for using custom breadcrumbs. In that example, it shows that you can use the BaseBreadcrumbMixin with the View class. However, when i try this in my codebase, I get the following error:

...
  File "/<path_to>/site-packages/view_breadcrumbs/generic/base.py", line 71, in get_context_data
    return super(BaseBreadcrumbMixin, self).get_context_data(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'super' object has no attribute 'get_context_data'

I fixed the issue by including the ContextMixin class after the BaseBreadcrumbMixin class.

To Reproduce

from abc import ABC, abstractmethod
from django.urls import reverse
from django.views.generic import View
from view_breadcrumbs import BaseBreadcrumbMixin
from demo.models import TestModel
from django.utils.functional import cached_property


class CustomView(ABC, ..., BaseBreadcrumbMixin, View):
    template_name = "app/test/custom.html"

    @cached_property
    def crumbs(self):
        return [("My Test Breadcrumb", reverse("custom_view"))]

    @abstractmethod
    def get_context_data(self, **kwargs) -> dict[str, Any]:
        """Get the base context for rendering."""
        context = super().get_context_data(**kwargs)
        return {
            **context,
            ...
        }

What OS are you seeing the problem on?

Other

Expected behavior?

I either expect the docs to be correct or it working without the ContextMixin class.

Relevant log output

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions