tj-django/django-view-breadcrumbs

Example for index page

saileshkush95 opened this issue · 6 comments

Thanks for your works. But I'm facing problem when I'm trying to implement in index page please help me. I also want to pass custom httml class in template But i can't

Sure, have can you take a look at the demo app https://github.com/jackton1/django-view-breadcrumbs/tree/master/demo or you add some code snippets on where you're stuck.

I mean, that how can I use BaseBreadcrumbMixin. In index page or home page
CreateBreadcrumbMixin works perfectly for model create view but when ever I replace model with form_class I'm getting error called attribute error for same view.
Any thanks for quick response.

Oh okay you could simply add a crumbs property to the view.

class HomeView(BaseBreadcrumbMixin, ...):
    crumbs = [('Home', '')]

Once again Thanks , But its not working here is my screenshot.
Screenshot_20190723_073214
It doesn't display any things on index page. But in case of other views it works perfectly

Here's a sample

views.py

class TestHomeView(BaseBreadcrumbMixin, TemplateView):
    template_name = 'demo/index.html'
    crumbs = []

urls.py

# Home view
path('', views.TestHomeView.as_view(), name='test_root'),

index.html

{% load django_bootstrap_breadcrumbs %}
<!DOCTYPE html>
<html lang="en">
<head>
    <title>Test app</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
    {% block breadcrumbs %}
    <main>
        {% render_breadcrumbs 'django_bootstrap_breadcrumbs/bootstrap4.html' %}
    </main>
    {% endblock %}
</body>

Which renders

Screen Shot 2019-07-23 at 1 11 35 AM

Thanks Dude