Added template tag to get django version to allow flat admin specific classing for Django 1.9 or above.
parent
5dee27e077
commit
7e9d305c90
|
|
@ -9,9 +9,17 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.sortable .inline-related .module.aligned .fa {
|
.sortable .inline-related .module.aligned .fa {
|
||||||
|
margin: 5px 10px 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sortable .inline-related.flat-admin .module.aligned .fa {
|
||||||
margin: 9px 10px 0 0;
|
margin: 9px 10px 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sortable.inline-group .module .fa {
|
.sortable.inline-group .module .fa {
|
||||||
|
margin: 26px -10px 0 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sortable.inline-group.flat-admin .module .fa {
|
||||||
margin: 34px -10px 0 10px;
|
margin: 34px -10px 0 10px;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
{% load i18n admin_urls admin_static %}
|
{% load i18n admin_urls admin_static django_template_additions %}
|
||||||
|
{% get_django_version as django_version %}
|
||||||
<div class="inline-group" id="{{ inline_admin_formset.formset.prefix }}-group">
|
<div class="inline-group" id="{{ inline_admin_formset.formset.prefix }}-group">
|
||||||
<h2>{{ inline_admin_formset.opts.verbose_name_plural|title }} {% if inline_admin_formset.formset.initial_form_count > 1 %} - {% trans "drag and drop to change order" %}{% endif %}</h2>
|
<h2>{{ inline_admin_formset.opts.verbose_name_plural|title }} {% if inline_admin_formset.formset.initial_form_count > 1 %} - {% trans "drag and drop to change order" %}{% endif %}</h2>
|
||||||
{{ inline_admin_formset.formset.management_form }}
|
{{ inline_admin_formset.formset.management_form }}
|
||||||
{{ inline_admin_formset.formset.non_form_errors }}
|
{{ inline_admin_formset.formset.non_form_errors }}
|
||||||
|
|
||||||
{% for inline_admin_form in inline_admin_formset %}<div class="inline-related{% if forloop.last %} empty-form last-related{% endif %} {% if inline_admin_form.original %} has_original{% endif %}" id="{{ inline_admin_formset.formset.prefix }}-{% if not forloop.last %}{{ forloop.counter0 }}{% else %}empty{% endif %}">
|
{% for inline_admin_form in inline_admin_formset %}<div class="inline-related {% if django_version.major >= 1 and django_version.minor >= 9 %}flat-admin{% endif %} {% if forloop.last %} empty-form last-related{% endif %} {% if inline_admin_form.original %} has_original{% endif %}" id="{{ inline_admin_formset.formset.prefix }}-{% if not forloop.last %}{{ forloop.counter0 }}{% else %}empty{% endif %}">
|
||||||
<h3><b>{{ inline_admin_formset.opts.verbose_name|title }}:</b> <span class="inline_label">{% if inline_admin_form.original %}{{ inline_admin_form.original }}{% if inline_admin_form.model_admin.show_change_link and inline_admin_form.model_admin.has_registered_model %} <a href="{% url inline_admin_form.model_admin.opts|admin_urlname:'change' inline_admin_form.original.pk|admin_urlquote %}" class="inlinechangelink">{% trans "Change" %}</a>{% endif %}
|
<h3><b>{{ inline_admin_formset.opts.verbose_name|title }}:</b> <span class="inline_label">{% if inline_admin_form.original %}{{ inline_admin_form.original }}{% if inline_admin_form.model_admin.show_change_link and inline_admin_form.model_admin.has_registered_model %} <a href="{% url inline_admin_form.model_admin.opts|admin_urlname:'change' inline_admin_form.original.pk|admin_urlquote %}" class="inlinechangelink">{% trans "Change" %}</a>{% endif %}
|
||||||
{% else %}#{{ forloop.counter }}{% endif %}</span>
|
{% else %}#{{ forloop.counter }}{% endif %}</span>
|
||||||
{% if inline_admin_form.show_url %}<a href="{% url 'admin:view_on_site' inline_admin_form.original_content_type_id inline_admin_form.original.pk %}">{% trans "View on site" %}</a>{% endif %}
|
{% if inline_admin_form.show_url %}<a href="{% url 'admin:view_on_site' inline_admin_form.original_content_type_id inline_admin_form.original.pk %}">{% trans "View on site" %}</a>{% endif %}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
{% load i18n admin_urls admin_static admin_modify %}{% load cycle from future %}
|
{% load i18n admin_urls admin_static admin_modify django_template_additions %}{% load cycle from future %}
|
||||||
<div class="inline-group" id="{{ inline_admin_formset.formset.prefix }}-group">
|
{% get_django_version as django_version %}
|
||||||
|
<div class="inline-group {% if django_version.major >= 1 and django_version.minor >= 9 %}flat-admin{% endif %}" id="{{ inline_admin_formset.formset.prefix }}-group">
|
||||||
<div class="tabular inline-related {% if forloop.last %}last-related{% endif %}">
|
<div class="tabular inline-related {% if forloop.last %}last-related{% endif %}">
|
||||||
{{ inline_admin_formset.formset.management_form }}
|
{{ inline_admin_formset.formset.management_form }}
|
||||||
<fieldset class="module">
|
<fieldset class="module">
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
from itertools import groupby
|
from itertools import groupby
|
||||||
|
|
||||||
|
import django
|
||||||
from django import template
|
from django import template
|
||||||
try:
|
try:
|
||||||
from django import TemplateSyntaxError
|
from django import TemplateSyntaxError
|
||||||
|
|
@ -76,3 +78,9 @@ def dynamic_regroup(parser, token):
|
||||||
#We also need to hand the parser to the node in order to convert the value
|
#We also need to hand the parser to the node in order to convert the value
|
||||||
#for `expression` to a FilterExpression.
|
#for `expression` to a FilterExpression.
|
||||||
return DynamicRegroupNode(target, parser, expression, var_name)
|
return DynamicRegroupNode(target, parser, expression, var_name)
|
||||||
|
|
||||||
|
|
||||||
|
@register.assignment_tag
|
||||||
|
def get_django_version():
|
||||||
|
version = django.VERSION
|
||||||
|
return {'major': version[0], 'minor': version[1]}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue