Django ORM extensions.


  • Django 1.8, 1.9, 1.10, 1.11
  • Python 2.7, 3.4, 3.5, 3.6

Supported databases

PostgreSQL, MySQL, SQLite


Install in your virtual environment.

Latest stable version from PyPI:

pip install django-ormex

Latest stable version from GitHub:

pip install


Common usage examples.


Contains various modules for aggregations.


Works like Concat, but for concatenating field values of related ManyToMany model. For instance, you may use it if you have an Author model as ManyToMany relation in the Book model (Book.authors = ManyToManyField(Author)) and you want to have concatenated list of all authors coupled to a given book.

Given the following models:

class Publisher(models.Model):

    name = models.CharField(max_length=255)
    address = models.CharField(max_length=255)
    city = models.CharField(max_length=255)
    state_province = models.CharField(max_length=255)
    country = models.CharField(max_length=255)
    website = models.URLField(max_length=255)

class Author(models.Model):

    salutation = models.CharField(max_length=255)
    name = models.CharField(max_length=255)
    email = models.EmailField(max_length=255)
    headshot = models.ImageField(upload_to='authors', null=True, blank=True)

class Book(models.Model):

    title = models.CharField(max_length=255)
    authors = models.ManyToManyField('books.Author', related_name='books')
    publisher = models.ForeignKey(Publisher, related_name='books')
    publication_date = models.DateField()
    isbn = models.CharField(max_length=255, unique=True)
    price = models.DecimalField(max_digits=10, decimal_places=2)
    pages = models.PositiveIntegerField(default=200)
    stock_count = models.PositiveIntegerField(default=30)

We could use GroupConcat as follows:

from ormex.aggregations import GroupConcat

book = Book.objects.all() \
                'publisher__name') \
            authors__name=GroupConcat('authors__name', separator=', ')
        ) \

Output would look as follows:

    'authors__name': 'Finn Janssen, Dan Dijkman, Merel Wolf, Evy de Jong',
    'id': 14,
    'pages': 83,
    'price': Decimal('62.13'),
    'publisher__id': 19,
    'publisher__name': 'Rijn, de Bruyn and Verharen',
    'title': 'Laboriosam officia temporibus facere omnis odit.'


Run demo locally

In order to be able to quickly evaluate the django-ormex, a demo app (with a quick installer) has been created (works on Ubuntu/Debian, may work on other Linux systems as well, although not guaranteed). Follow the instructions below to have the demo running within a minute.

Grab the latest

wget -O - | bash

Open your browser and test the app.

If quick installer doesn’t work for you, see the manual steps on running the example project.


Simply type:


or use tox:


or use tox to check specific env:

tox -e py35

or run Django tests:

./ test ormex --settings=settings.testing


GPL 2.0/LGPL 2.1


For any issues contact me at the e-mail given in the Author section.


Artur Barseghyan <>