Skip to main content

A simple Luigi app to connect django and luigi.

Project description


Luigi is a simple Django app to be able to link Django to the workflow manager luigi.

Quick start

1. Add 'django_luigi' to you INSTALLED_APPS settings like this::


2. Create your `app` and `models` in Django as usual

3. Run `python migrate` to create the models.

You can know create objects in your luigi pipeline.

Assuming a django model Test in the test app with two CharField, item1, and item2, properly migrated

.. code-block:: python
from django.db import models

class Test(models.Model):
item1 = models.CharField(max_length=120)
item2 = models.CharField(max_length=120)

Here is a minimal example of a job to copy data to database using Django :

.. code-block:: python

import luigi
from django_luigi.django import ToORM

class TestTask(ToORM):

django_root = 'path_to_your_django_root' # Where is
settings_path = 'my_site.settings'

model = 'Test'
app = 'test'

def rows(self):
for row in [("item1", "property1"), ("item2", "property2")]:
yield row

if __name__ == '__main__':
task = TestTask()[task], local_scheduler=True)

In the above examples, the data that needs to be copied was directly provided by
overriding the rows method. Alternately, if the data comes from another task, the
modified example would look as shown below:

.. code-block:: python

import luigi
from django_luigi.django import ToORM
from luigi.mock import MockTarget

class BaseTask(luigi.Task):
def output(self):
return MockTarget("BaseTask")

def run(self):
out = self.output().open("w")
TASK_LIST = ["item%d\\tproperty%d\\n" % (i, i) for i in range(1,3)]
for task in TASK_LIST:

class TestTask(ToORM):

django_root = 'path_to_your_django_root' # Where is
settings_path = 'my_site.settings'

model = 'Test'
app = 'test'

def requires(self):
return BaseTask()

if __name__ == '__main__':
task1, task2 = TestTask(), BaseTask()[task1, task2], local_scheduler=True)

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-luigi, version 0.2
Filename, size File type Python version Upload date Hashes
Filename, size django_luigi-0.2-py2-none-any.whl (8.6 kB) File type Wheel Python version py2 Upload date Hashes View
Filename, size django-luigi-0.2.tar.gz (5.5 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page