Closed KrunchMuffin closed 5 years ago
It's been a while since I wrote any django code but I'm sure we can crack it together.
I think it's because {% render_breadcrumbs %}
is called to early. I would try moving it out of templates/base/breadcrumb.html
and into templates/base/base.html
or maybe even templates/accounts/index.html
to see if that helps.
That's the only quick tip I have right now, let me know if that still doesn't work.
Hey! Thanks for the quick reply!
I tried it in different places with same result. So confused.
🤔 I'll look into this over weekend, should be easy to reproduce
Thanks. I'll keep pluggin' away.
I think I got it! I took all the breadcrumb.html code and replaced the include inside base.html with it and it worked. So I guess there is an issue with includes?
I have a question while I have you. In paths where I have an ID ie. 159, would it be possible to replace that with the actual company name it represents and use it in the breadcrumb? So...
From path /accountmgmt/154/detail/
Dashboard / Accounts / ACME Inc. / Detail
I think that if you only got Dashboard
than it's an ordering issue (rendering breadcrumbs list before it was fully populated), so it might be related to the way inheritance chain is setup.
I have a question while I have you. In paths where I have an ID ie. 159, would it be possible to replace that with the actual company name it represents and use it in the breadcrumb? So...
Dashboard / Accounts / ACME Inc. / Detail
If you are using Django models than you can define str() and pass model instance as $label
argument (docs) or pass any model attribute there as $label
Ok, cool. thanks again.
Hey again.
Having a small issue I can't figure out.
I get this far
But when I select a user to view detail on, I lose the company name
Goes like this...
Dashboard: (base.html)
{% breadcrumb "Dashboard" "/dashboard" %}
Account List: (index.html)
{% extends 'base/base.html' %}
{% breadcrumb "Account List" "accountmgmt:account-list" %}
Martin's Cafe: (detail.html)
{% extends 'accounts/index.html' %}
{% breadcrumb detail.company_name|title "accountmgmt:account-detail" detail.profile_id %}
User List: (userlist.html)
{% extends 'accounts/index.html' %}
{% breadcrumb company_name|title "accountmgmt:account-detail" pid %}
{% breadcrumb "User List" "accountmgmt:user-list" pid %}
Big Boss: (userdetail.html)
{% extends 'accounts/userlist.html' %}
{% breadcrumb detail.fullname|title "accountmgmt:user-detail" detail.user_id %}
Is the detail
object the user or the company? Does that one object have all those attributes you use? (company_name
, profile_id
, user_id
)
hmmm...not likely. it would have company and profile but not user
Doesn't this mean that detail
object used when you render those breadcrumbs can't render all of those, since for some breadcrumbs it needs to be a user but for others it's a company?
I mean - when you render user page detail
object is an user object, so when partial for rendering company title gets that passed it can't find company_name
on it.
I would recommend using more meaningful object names so it's obvious what you need to pass.
Finally figured it out. Did a select_related for the account.
Full disclosure, I am a django/python newbie.
this is what I have
templates/base/base.html
templates/base/breadcrumb.html The initial "Dashboard" works.
templates/accounts/index.html
All I end up with is
Dashboard
. I have tried different configurations. There are no errors. Django 2.1.2 Python 3.7