-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
django-grappelli support #4
Comments
I'll see what I can do, in the next week. Since we override the breadcrumbs, it may be a matter of just adding some CSS classes to the templates. If you're able to do this already in the meantime, I'd be happy to accept the pull request of course. |
Hi, Ive addressed the list appearance in a5c76f6 it should look proper now. The breadcrumbs are still off, as django-grapelli uses different HTML formatting to format them. I'm not sure yet how I'll implement that. Either it could be a separate template, or a |
Seems like this issue has languished for a while. I'd like to re-open it and get this problem solved for the breadcrumbs. For comparison, let's look at the Change Form templates. Here is the current template in django-polymorphic-tree: {% extends "admin/change_form.html" %}
{% load i18n admin_modify polymorphic_admin_tags polymorphic_tree_admin_tags %}
{# Add tree levels to polymorphic breadcrumb #}
{% block breadcrumbs %}{% if not is_popup %}{% breadcrumb_scope base_opts %}
<div class="breadcrumbs">
<a href="../../../">{% trans "Home" %}</a> ›
<a href="../../">{{ app_label|capfirst|escape }}</a> ›
{% if has_change_permission %}<a href="../">{{ opts.verbose_name_plural|capfirst }}</a>{% else %}{{ opts.verbose_name_plural|capfirst }}{% endif %} ›
{% for p in original|mptt_breadcrumb %}
<a href="../{{ p.id }}/">{{ p }}</a> ›
{% endfor %}
{% if add %}{% trans "Add" %} {{ opts.verbose_name }}{% else %}{{ original|truncatewords:"18" }}{% endif %}
</div>
{% endbreadcrumb_scope %}{% endif %}{% endblock %} Here is the relevant block from Grappelli's {% block context-navigation %}
<!-- CONTEXT NAVIGATION -->
<div id="grp-context-navigation">
<nav id="grp-breadcrumbs" class="{% block breadcrumbs-class %}{% endblock %}">
<header style="display:none"><h1>Breadcrumbs</h1></header>
{% block breadcrumbs %}
<ul>
<li><a href="{% url 'admin:index' %}">{% trans 'Home' %}</a></li>
{% if title %}
<li> › {{ title }}</li>
{% endif %}
</ul>
{% endblock %}
</nav>
<nav id="grp-page-tools">
<header style="display:none"><h1>Page Tools</h1></header>
{% block page-tools %}{% endblock %}
</nav>
</div>
{% endblock %} <!-- BREADCRUMBS -->
{% block breadcrumbs %}
{% if not is_popup %}
<ul>
<li><a href="{% url 'admin:index' %}">{% trans "Home" %}</a></li>
<li><a href="{% url 'admin:app_list' app_label=opts.app_label %}">{{ opts.app_config.verbose_name }}</a></li>
<li>{% if has_change_permission %}<a href="{% url opts|admin_urlname:'changelist' %}">{{ opts.verbose_name_plural|capfirst }}</a>{% else %}{{ opts.verbose_name_plural|capfirst }}{% endif %}</li>
<li>{% if add %}{% trans "Add" %} {{ opts.verbose_name }}{% else %}{{ original|truncatewords:"18" }}{% endif %}</li>
</ul>
{% endif %}
{% endblock %} And finally, the standard Django admin's breadcrumbs from {% block breadcrumbs %}
<div class="breadcrumbs">
<a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
{% if title %} › {{ title }}{% endif %}
</div>
{% endblock %} {% block breadcrumbs %}
<div class="breadcrumbs">
<a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
› <a href="{% url 'admin:app_list' app_label=opts.app_label %}">{{ opts.app_config.verbose_name }}</a>
› {% if has_change_permission %}<a href="{% url opts|admin_urlname:'changelist' %}">{{ opts.verbose_name_plural|capfirst }}</a>{% else %}{{ opts.verbose_name_plural|capfirst }}{% endif %}
› {% if add %}{% trans 'Add' %} {{ opts.verbose_name }}{% else %}{{ original|truncatewords:"18" }}{% endif %}
</div>
{% endblock %} So, the changes in the HTML are relatively minor and can be implemented with an assignment tag that detects whether Grappelli is being used. Note there is a distinction between Grappelli appearing in There is thus no way to detect Grappelli at runtime. Honestly, I don't think that's the right idea though. Rather, the best option is to have a Thoughts? See: https://docs.djangoproject.com/en/1.7/howto/custom-template-tags/#assignment-tags |
Have a look at django-mptt. It utilizes IS_GRAPPELLI_INSTALLED = 'grappelli' in settings.INSTALLED_APPS To load different templates. |
Agreed @robslotboom, I'd accept a pull request when it cleanly provides support for both! |
django-grappelli is a very popular theme for django admin.
https://github.com/sehmaschine/django-grappelli
When django-polymorphic-tree works with django-grappelli, the templates, breadcrumbs and actions for models seem to be broken. Is it possible for django-polymorphic-tree to support django-grappelli in the future release?
The text was updated successfully, but these errors were encountered: