Skip to content
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

Add unsaved changes warning to admin #13

Open
eeriksp opened this issue Sep 27, 2018 · 0 comments
Open

Add unsaved changes warning to admin #13

eeriksp opened this issue Sep 27, 2018 · 0 comments

Comments

@eeriksp
Copy link
Member

eeriksp commented Sep 27, 2018

Add JS

Code snippet is here, add

'use strict'
var $ = django.jQuery

at the beginning of the file.

Add script to admin views

  1. Alter settings.py:
TEMPLATES = [
    {
        ...
        'DIRS': [os.path.join(BASE_DIR, 'templates'),],
        ...
    },
]
  1. Add src/templates/admin/base_site.html:
{% extends 'admin/base.html' %}
{% block responsive %} {# Use 'responsive' instead of 'extrahead' in order to ensure right js files order #}
{{ block.super }}
<script type="text/javascript" src="/static/media/common/js/unsaved-changes-warning.js"></script>
{% endblock %}
  1. Add tests

Alternative possibility:

see this package

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant