Giter VIP home page Giter VIP logo

bootstrap-breadcrumbs's Introduction

django-bootstrap-breadcrumbs

Version

See https://django-bootstrap-breadcrumbs.readthedocs.org/en/latest/

Testing

Included Dockerfile allows to run tests using python3 from debian jessie.

Test with the most recent django version::

docker build .

To specify django version to use for testing set the version via DJANGO arg to docker::

docker build --build-arg DJANGO===1.9.1 .

DJANGO argument will be passed to pip using pip install Django${DJANGO}, so you can pass any version string pip accepts (==version, >=version).

To make testing easier there is a Makefile provided which wraps docker commands.

Run tests agains multiple versions of Django set in Makefile::

make

To run tests against any version run::

make $VERSION

Example::

make 1.10.2

bootstrap-breadcrumbs's People

Contributors

bitdeli-chef avatar cvrebert avatar ekohl avatar gnuwho avatar jelouemoncampingcar avatar jp-ellis avatar prymitive avatar rolandgeider avatar tony avatar vladimirnani avatar xchrdw avatar zopieux avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

bootstrap-breadcrumbs's Issues

Space between slash and crumb

Version: django-bootstrap-breadcrumbs==0.9.1

The breadcrumbs should looks like Home / Users / John Doe but it looks like Home /Users /John Doe. (See the lack of space between the slash and the word)

base.py

  {% block breadcrumbs %}
    {% breadcrumb "Home" "/" %}
  {% endblock %}

users.py

{% block breadcrumbs %}
  {{ block.super }}
  {% breadcrumb "Users" "users" %}
{% endblock %}

profile.py

{% block breadcrumbs %}
  {{ block.super }}
  {% breadcrumb id "users.views.profile" user.username %}
{% endblock %}

The fix I'm using:

ul.breadcrumb span.divider{
  margin-right: 5px;
}

How to add additional html class for render_breadcrumbs?

by default, the {% render_breadcrumbs %} rendered the html breadcrumb like this below example:

<nav aria-label="breadcrumb">
  <ol class="breadcrumb">
    <li class="breadcrumb-item"><a href="/">Home</a></li>
    <li class="breadcrumb-item"><a href="/quizzes/">Quizzes</a></li>
    <li class="breadcrumb-item active" aria-current="page">Quiz Python Programming</li>
  </ol>
</nav>

but, for some case I need to add new the thml class inside that
<ol class="breadcrumb">, e.g: <ol class="breadcrumb bg-light">.

Is there any support for it? e.g: {% render_breadcrumbs add_class:"bg-light foobar baz" %}

No module named 'django.core.urlresolvers'

As of version 2.0 of Django is no longer an application to module 'django.core.urlresolvers'. Follow the message:

Deprecated since version 1.10:
In older versions, these functions are located in django.core.urlresolvers. Importing from the old location will continue to work until Django 2.0

For a generic solution, you can do the following:

# ... imports

if VERSION < (2, 0):
    from django.core.urlresolvers import (reverse, resolve, NoReverseMatch,
                                          Resolver404)
else:
    from django.urls import (reverse, resolve, NoReverseMatch,
                             Resolver404)

# ... Remainder of code

Deprecation warnings under django-3.0

django_bootstrap_breadcrumbs/templatetags/django_bootstrap_breadcrumbs.py:81: RemovedInDjango40Warning: django.utils.translation.ugettext() is deprecated in favor of django.utils.translation.gettext().
append_breadcrumb(context, _(escape(label)), viewname, args, kwargs)
django_bootstrap_breadcrumbs/templatetags/django_bootstrap_breadcrumbs.py:147: RemovedInDjango40Warning: smart_text() is deprecated in favor of smart_str().
links.append((url, smart_text(label) if label else label))

Make TEMPLATE_CONTEXT_PROCESSORS checks smarter or more lenient

I see django_bootstrap_breadcrumbs.templatetags.django_bootstrap_breadcrumbs: ERROR: request object not found in context! Check if 'django.core.context_processors.request' is in TEMPLATE_CONTEXT_PROCESSORS in my test run all of the time โ€“ could this check be made smarter โ€“ could just check the setting itself?

django.core.context_processors.request is in my TEMPLATE_CONTEXT_PROCESSORS, the request isn't available because the template is manually rendered.

I add_to_builtins('django_bootstrap_breadcrumbs.templatetags.django_bootstrap_breadcrumbs') in urls.py, so I don't have to write {% load django_bootstrap_breadcrumbs %} everywhere. Is this a bad idea, should I stop? Or should this just not error like this?

https://github.com/prymitive/bootstrap-breadcrumbs/blob/master/django_bootstrap_breadcrumbs/templatetags/django_bootstrap_breadcrumbs.py#L95-L97

Labels are not links

Hi!

The labels won't render as clickable links (<a>).

This is the template:

{% load django_bootstrap_breadcrumbs %}

{% block breadcrumbs %}
    {% clear_breadcrumbs %}
    {% breadcrumb "Home" "app:index" %}
{% endblock %}

{% block content %}
  {% render_breadcrumbs %}
...
{% endblock %}

This is the app url:

...
path('', IndexView.as_view(), name='index'),
...

Dynamic variable to view function

How to assign dynamic variable as viewname in {% breadcrumb forum_name "topic" parameter=forum_name %}
instead of "topic" i need to use "topic"+dynamic variable.

how to do like that?

Unable to past HTML as label

My issue interfere with pull request in #6, but anyway, there are cases when I need to show for example icon and not a plain text as a label:

{% block breadcrumbs %}
    {% breadcrumb '<i class="icon-home"></i>' 'myapp.views.home' %}
{% endblock %}

I would be pleased if this would also be possible.

smart_text() is deprecated in favor of smart_str()

Using django-bootstrap-breadcrumbs 0.9.2 with Django 3.0.7, I get the following deprecation warning:

lib/python3.8/site-packages/django_bootstrap_breadcrumbs/templatetags/django_bootstrap_breadcrumbs.py:151: RemovedInDjango40Warning: smart_text() is deprecated in favor of smart_str().
  links.append((url, smart_text(label) if label else label))

Checking the Django source it looks like smart_text() is now just a call to smart_str().

Issues with crumb not appearing

Full disclosure, I am a django/python newbie.

this is what I have

templates/base/base.html

...
<!-- Main content -->
<main class="main">

    <!-- Breadcrumb -->
    {% include 'base/breadcrumb.html' %}

    <!-- Page contents -->
    <div class="container-fluid">
        <div class="animated fadeIn">
            {% block content %}
            {% endblock %}
        </div>

    </div>
    <!-- /.conainer-fluid -->
</main>

...

templates/base/breadcrumb.html
The initial "Dashboard" works.

{% load static %}
{% load django_bootstrap_breadcrumbs %}

{% block breadcrumbs %}
    {% breadcrumb "Dashboard" "/dashboard" %}
{% endblock %}

{% block breadcrumb %}
    {% render_breadcrumbs %}
{% endblock %}

templates/accounts/index.html

{% extends 'base/base.html' %}
{% load static %}
{% load django_bootstrap_breadcrumbs %}
{% block breadcrumbs %}
    {{ block.super }}
    {% breadcrumb "Account List" "account-list" %}
{% endblock %}
{% load common_extras %}
{% block content %}

All I end up with is Dashboard. I have tried different configurations. There are no errors.
Django 2.1.2 Python 3.7

bootstrap_for template tag does not support named view with namespace

bootstrap_for template tag does not support named view with namespace

myapp urls.py

urlpatterns = patterns('',
    url(r'^create/$', 'myadd.view.myview_create',  name='make_magic' ),
)

project urls.py

urlpatterns = patterns('',
    url(r'^$', include("myapp.urls", namespace="myapp")),
)

on template:

{% load i18n %}
{% load django_bootstrap_breadcrumbs %}

{% block breadcrumb_head %}
    {% clear_breadcrumbs %}
    {% breadcrumb_for "myapp:make_magic" %}
        {% trans "Make Magic" %}
    {% endbreadcrumb_for %}
{% endblock breadcrumb_head %}

The result is an incorrect url. The generated code is:

<a href="myapp:make_magic">
        Make Magic
    </a>

the django url template tag can properly resolve this url.
I suppose that perhaps part of the code solves the url, could be replaced by a direct call to the django url template tag

named route and kwargs not respected

Hello,

In template I should have this:

   {% load django_bootstrap_breadcrumbs %}
   {% block breadcrumbs %}
        {% clear_breadcrumbs %}
        {% breadcrumb 'My Collections' 'app_collections_index' %}
        {% breadcrumb collection "app_collections_view" id=collection.uiid %}
        {% breadcrumb "Edit" "app_collections_edit" id=collection.uiid %}
    {% endblock %}

The breadcrumb link for 'app_collections_view` outputs:

http://localhost:8000/collections/32c9fdd9-de41-4bb0-9ea6-7a30371df43e/app_collections_view

It should generate the proper url of:

http://localhost:8000/collections/32c9fdd9-de41-4bb0-9ea6-7a30371df43e

For some reason it is completely ignore the route name and kwargs...

Thanks in advance!

Labels translation not working

Only Django default words like 'home', 'user' are translated while using:

{% breadcrumb "Home" "/" %} {% breadcrumb "User" "users" %}

But any word not recognized (by default) by Django is not translated, for example:

{% breadcrumb "Your Account" "account" %} {% breadcrumb "Profile" "profile" %}

I'm loading i18n in the template and USE_I18N is set to True in settings.py but I cannot find any .po file containing the label text to be translated. If I use the trans tag in the very same template then the text appears correctly in the .po file after running makemassages.

Any ideias?

Make it possible to use get_absolute_url

In addition to #3 which made it possible to just display objects, wouldn't it be easy if you could just use get_absolute_url to build URLs? Maybe add some logic that if no viewname is given and the label has the attribute get_absolute_url that is used?

No spacing after divider "/"

I've have three crumbs and they don't get a space after the "/" but in the examples, there is a space.

What I expect

Home / One / Two

What I get

Home /One /Two

{% breadcrumb "Home" "app:home" %}
{% breadcrumb "One" "app:one" %}
{% breadcrumb "Two" "app:two" %}

kwargs are not supported?

{% breadcrumb customer 'customer-details' cust_id=customer.id %}

TemplateSyntaxError at /customers/edit-contact/2/3/
'breadcrumb' received unexpected keyword argument 'cust_id'

Since you were using reverse, I would have expected it to allow for kwargs as well as positional args.

How user with Class View ?

How can I use with url MyListView.as_view() ?

Like:

{% breadcrumb "My View" "MyviewListView.as_view()" %}

My url:
url(r'^myview/view/(?P[0-9]+)/$', MyViewDetail.as_view(), name='myview_detail'),

Thank's a lot.

Replace GPL with a more permissive license, like BSD or MIT

I am developing a project for the state government of my country, and unfortunately, my leadership changed his mind and would not let me open the code.

I know this is a stupid request, so excuse me for that.

Is possible to do this replacement?

Templatetag is causing 'RemovedInDjango110Warning: render() must be called with a dict, not a RequestContext.'

When I run django-bootstrap-breadcrumbs in Django 1.9.10, I get the following deprecation warning:

RemovedInDjango110Warning: render() must be called with a dict, not a RequestContext.

This is because the render_breadcrumbs receives a RequestContext object and then subsequently passes it to render_to_string.

I suggest something along the lines of this, where we check the Django version and if it's 1.9 or later than we go through the RequestContext object and puts it into a dict, before passing it.

from distutils.version import StrictVersion
import django

def render_breadcrumbs(context, *args):
...
    if StrictVersion(django.get_version()) >= StrictVersion('1.9'):
        # Passing a RequestContext to render_to_string is deprecated or not allowed; convert the context to a dict
        context_dict = {}
        for d in context.dicts:
            context_dict.update(d)
        return mark_safe(template.loader.render_to_string(
            template_path, context_dict, request=context['request']))

Templates not working as expected

Hi,

If I build templates like in the doc examples, nothing is displayed:

{% load django_bootstrap_breadcrumbs %}
{% block breadcrumbs %}
    {% breadcrumb "Users and groups" "/" %}
{% endblock %}

{% block content %}
    {% render_breadcrumbs %}
    {% crispy form %}
{% endblock %}

This works (everything in the block):

{% load django_bootstrap_breadcrumbs %}

{% block content %}
    {% block breadcrumbs %}
        {% breadcrumb "Users and groups" "/" %}
    {% endblock %}
    {% render_breadcrumbs %}
    {% crispy form %}
{% endblock %}

May it helps...

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.