django-admin-export

Software Screenshot:
django-admin-export
Software Details:
Version: 1.5
Upload Date: 20 Feb 15
Developer: David Burke
Distribution Type: Freeware
Downloads: 23

Rating: 2.0/5 (Total Votes: 1)

django-admin-export is a Django app that adds a global action to Django admin to export to XLS.

Install

- easy_install django-admin-export
- Add admin_export to Installed Apps
- Add (r'^admin_export/', include("admin_export.urls")), to urls.py
- Recommended - Add jquery to django admin edit pages.
- Recommended - Customize template to make it look cool!

Customizing the template

You will need a moderate level of understanding on overriding django templates, jquery, and ajax to do this. By default the action will take you to a separate page and Foreign keys will not work, because they rely on jquery ajax. I choose to have mine use ajax to keep the page on the admin change list itself and load in foreign key fields as needed. I also use Grappelli, if you don't you will need to modify this a bit. To do this, override /admin/change_list.html

My customization makes use of jquery tool to create a nice overlay.

{% extends "grappelli/templates/admin/change_list.html" %}

{% block stylesheets %}
 {{ block.super }}
 < style type="text/css" >
 .modal {
 background-color:#fbfdfd;
 display:none;
 width:550px;
 padding:20px;
 text-align:center;
 border:3px solid #333;
 
 opacity:0.98;
 border-radius:12px;
 -moz-border-radius:12px;
 -webkit-border-radius:12px;
 box-shadow: 20px 20px 200px black;
 -moz-box-shadow: 20px 20px 200px black;
 -webkit-box-shadow: 20px 20px 200px black;
 z-index: 999;
 }
 < /style >
{% endblock %}

{% block javascripts %}
 < script src="/static/js/jquery.tools.min.js" type="text/javascript" >< /script >
 {{ block.super }}
 < !-- Edited grappelli/js/actions.min.js to show overlaw when needed -- >
 < script type="text/javascript" >
 $(document).ready(function() {
 $("select[name=action]").change(function() {
 if ( $("option[value=export_simple_selected_objects]:selected").length ) {
 $.post(
 "",
 $("#changelist-form").serialize(),
 function(data){
 $("#export_xls_form").html(data);
 }
 );
 $("#export_xls_form").overlay({
 top: '3',
 fixed: false
 });
 $("#export_xls_form").overlay().load();
 return false;
 }
 });
 });
 < /script >
{% endblock %}

{% block content %}
 {{ block.super }}
 < !-- Overlay -- >
 < div class="modal" id="export_xls_form" >< button class="close" > Close < /button >< /div >
{% endblock %}


Have a better solution? Maybe one that doesn't require jquery? Contact me or put in a enhancement request! Read more about the plugin on my blog.

Features:

  • Export to XLS
  • Export related fields (requires JQuery)
  • Check off fields you want to export
  • Use Django admin's filter for simple query needs

Requirements:

  • Python
  • Django

Other Software of Developer David Burke

Comments to django-admin-export

Comments not found
Add Comment
Turn on images!