Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install django-data-exporter

How to install django-data-exporter

  1. Download and install ActivePython
  2. Buy and install the Business Edition license from account.activestate.com
  3. Open Command Prompt
  4. Type pypm install django-data-exporter

django-data-exporter contains builds that are only available via PyPM when you have a current ActivePython Business Edition subscription.

 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
Windows (64-bit)
Mac OS X (10.5+)
Linux (32-bit)
0.6.8
0.6.8 Available View build log
0.6.4 Available View build log
0.5.2 Available View build log
0.5.1 Available View build log
0.5 Available View build log
0.4.1 Available View build log
Linux (64-bit)
0.5.2
0.6.8Never BuiltWhy not?
0.5.2 Available View build log
0.5.1 Available View build log
0.5 Available View build log
0.4.1 Available View build log
Web
 
Author
Lastest release
version 0.1.5 on Jul 19th, 2013

django-data-exporter is a simple Django application to export asynchronously your data from your models.

It's based on Celery (>= 2.3) to use Chords and tablib to export your data in multiple formats.

Installation

  1. Either check out the package from GitHub or it pull from a release via PyPI

    pip install django-data-exporter
    
  2. Configure your Django project to use djcelery

  3. Add 'data_exporter' to your INSTALLED_APPS

    INSTALLED_APPS = (
        'data_exporter',
    )
    

Utilisation

django-data-exporter uses channels to discover your exports and to transfer them to celery. So let's say you have the following model in a polls application

# polls/models.py
from django.db import models


class Poll(models.Model):
    question = models.CharField(max_length=200)
    pub_date = models.DateTimeField('date published')

    def __unicode__(self):
        return self.question

Now, you want to define your first exporter right? Create a exports.py file in your polls application and extend Export to build your own Exporter

# polls/exports.py
from data_exporter.base import Export

from polls.models import Poll


class PollExport(Export):
    filename = 'poll'
    columns = ('id', 'question')
    headers = ('id', 'question')
    directory = 'polls'

    def get_query(self, offset=None, limit=None):
        qs = Poll.objects.all()

        if offset and limit:
            return qs[offset:limit]

        if limit:
            return qs[:limit]

        if offset:
            return qs[offset:]

        return qs

    def get_count(self):
        return Poll.objects.count()

Final step is to register this exporter in DATA_EXPORTER_CHANNELS in your Django settings

DATA_EXPORTER_CHANNELS = {
    'polls': 'polls.exports.PollExport'
}

You can now use the celery tasks provided by django-data-exporter as so

from data_exporter.tasks import builder
builder.delay('polls', 'csv')

First parameter is the name of your channel and second parameter is the format wanted.

As said before, we use the beautiful tablib library to export your data, so as you may understood we support all formats provided by this library.

Configuration

DATA_EXPORTER_CHANNELS

All your registered channels.

DATA_EXPORTER_DIRECTORY

The directory used to export your data.

Subscribe to package updates

Last updated Jul 19th, 2013

Download Stats

Last month:2

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.