Skip to content

Instantly share code, notes, and snippets.

@thorin-schiffer
Created December 31, 2021 15:20
Show Gist options
  • Save thorin-schiffer/ec40fe01e8708e01dc67ea4b85721dac to your computer and use it in GitHub Desktop.
Save thorin-schiffer/ec40fe01e8708e01dc67ea4b85721dac to your computer and use it in GitHub Desktop.
Django-plpy annotations
from django.db.models import F, Func
from tests.books.models import Book
Book.objects.annotate(
max_value=Func(F("amount_sold"), F("amount_stock"), function="pl_max")
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment