-
Notifications
You must be signed in to change notification settings - Fork 95
Home
abidibo edited this page Feb 15, 2021
·
6 revisions
Django Baton v2 is not fully backward compatible, in the sense that it drops support for Django 1 and python 2. So who is still using Django < 2.1 should continue using baton 1.13.
Migrating from Baton 1 to Baton 2 is straightforward. It should just work unless you've overridden the admin/base_site.html
template. In such case you should edit it to respect the new template which uses a different approach to inject options in Baton module:
{% extends "admin/base.html" %}
{% load static baton_tags %}
{% load i18n %}
{% block title %}{{ title }} | {{ site_title|default:_('Django site admin') }}{% endblock %}
{% block extrahead %}
<meta content="width=device-width, initial-scale=1.0" name="viewport" />
<script src="{% static 'baton/app/dist/baton.min.js' %}"></script>
<!-- <script src="http://localhost:8080/dist/baton.min.js"></script> -->
{% baton_config as conf %}
{{ conf | json_script:"baton-config" }}
<script>
(function ($, undefined) {
$(document).ready(function () {
Baton.init(JSON.parse(document.getElementById('baton-config').textContent));
})
})(jQuery, undefined)
</script>
{% endblock %}
{% block branding %}
<h1 id="site-name"><a href="{% url 'admin:index' %}">{{ site_header|default:_('Django administration') }}</a></h1>
{% endblock %}
{% block nav-global %}{% endblock %}
{% block footer %}
{% footer %}
{% endblock %}
This is the new admin/base_site.html
template, so you need to change your template to respect the relevant parts which differ on respect to previous versions:
{% baton_config as conf %}
{{ conf | json_script:"baton-config" }}
<script>
(function ($, undefined) {
$(document).ready(function () {
Baton.init(JSON.parse(document.getElementById('baton-config').textContent));
})
})(jQuery, undefined)
</script>