This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

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 not offset is None and not limit is None:
            return qs[offset:limit]

        elif limit:
            return qs[:limit]

        elif 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.

Release History

Release History

0.2

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.5

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.4

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django-data-exporter-0.2.tar.gz (5.8 kB) Copy SHA256 Checksum SHA256 Source Sep 4, 2013

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting