Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Taking the O out of ORM.

Project Description

Django model utilities for encouraging direct data access instead of unnecessary object overhead. Implemented through compatible method and operator extensions to QuerySets and Managers.

The goal is to provide elegant syntactic support for best practices in using Django’s ORM. Specifically avoiding the inefficiencies and race conditions associated with always using objects.


Typical model usage is verbose, inefficient, and incorrect.

book = Book.objects.get(pk=pk)
book.rating = 5.0

The correct method is generally supported, but arguably less readable.


model_values encourages the better approach with operator support.

Book.objects[pk]['rating'] = 5.0

Similarly for queries:

(book.rating for book in books)
books.values_list('rating', flat=True)

Column-oriented syntax is common in panel data layers, and the greater expressiveness cascades. QuerySets also support aggregation and conditionals.

books.values_list('rating', flat=True).filter(rating__gt=0)
books['rating'] > 0


Managers provide a variety of efficient primary key based utilities. To enable, instantiate the Manager in your models. As with any custom Manager, it doesn’t have to be named objects, but it is designed to be a 100% compatible replacement.

from model_values import Manager

class Book(models.Model):
   objects = Manager()

F expressions are also enhanced, and can be used directly without model changes.

from model_values import F

.filter(rating__gt=0, last_modified__range=(start, end))
.filter(F.rating > 0, F.last_modified.range(start, end))

Read the documentation.


$ pip install django-model-values


  • django >=1.8


100% branch coverage.

$ pytest [--cov]



  • F expressions operators any and all
  • Spatial lookups and functions
  • Django 2.0 support


  • upsert method
  • Django 1.9 database functions
  • bulk_update supports additional fields


  • Lookup methods and operators
  • F expressions and aggregation methods
  • Database functions
  • Conditional expressions for updates and annotations
  • Bulk updates and change detection


  • Change detection
  • Groupby functionality
  • Named tuples
Release History

Release History

This version
History Node


History Node


History Node


History Node


History Node


History Node


Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django_model_values-0.5.1-py2.py3-none-any.whl (10.5 kB) Copy SHA256 Checksum SHA256 py2.py3 Wheel Dec 12, 2017
django-model-values-0.5.1.tar.gz (22.2 kB) Copy SHA256 Checksum SHA256 Source Dec 12, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS 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