$npx skillfedfor your agent

django-pg-returning

A small library implementing PostgreSQL ability to return rows in DML statements for Django

With conditionsPyPI DatabaseReleased Jan 2024178.5K downloads / mopermissive licensePure Python

Decision gist · record as of 2026-08-14

pure-Python wheel — django_pg_returning-2.0.2-py2.py3-none-any.whl
v2.0.2 · released 2024-01-04 · 2 runtime deps: django, typing

Yes, if you use PostgreSQL and Django and frequently need to return modified rows from bulk operations or F() expressions. The library is stable and has no known vulnerabilities, but its dormant maintenance (last release 2024-01-04, no recent commits) means it may not support the latest Django versions—verify compatibility with your Django version before adopting. Low install friction and permissive licensing make it a low-risk experiment.AI-flagged interpretation of the facts on this page — verify before relying

Before you install

  • Requires PostgreSQL 9.4+, psycopg2 or psycopg2-binary (not installed by this package), and Django 1.8+.
  • Some features require Django 1.10+.
  • Low friction: pure Python wheel with only django and typing as runtime dependencies.

License · maintenance · safety

permissive license (permissive) — BSD 3-clause permissive license; you may use, modify, and distribute freely with attribution and no warranty.

last release 2024-01-04 (953 days) · last repo commit 2024-09-19 · 18 stars

0 known vulnerabilities (OSV.dev, 2026-08-14) · 178,490 downloads/mo, #10,192 on PyPI

Verify before relying

pip install django-pg-returning

from django_pg_returning import UpdateReturningModel
from django.db import models

class MyModel(UpdateReturningModel):
    field = models.IntegerField()

result = MyModel.objects.all().update_returning(field=1)
print(result.count())
  • Whether the library works with current Django versions (4.x, 5.x) given dormant maintenance status.
  • Compatibility with modern psycopg versions (3.x) and whether psycopg2 is still the expected adapter.
  • Performance characteristics when returning large result sets or with complex F() expressions.
Same gist for agents: .md · .json

What it is and what it does

django-pg-returning bridges a gap in Django's ORM: it exposes PostgreSQL's RETURNING clause for UPDATE, DELETE, and bulk CREATE operations. Normally, Django's update() and delete() methods don't return the modified rows, and bulk_create() doesn't refresh fields with database-computed defaults or trigger-set values. This library adds QuerySet methods (update_returning, delete_returning, create_returning, bulk_create_returning) and model methods (save_returning) that execute the DML statement and immediately fetch back the affected rows, including any values computed by the database.

The result is a ReturningQuerySet—a cached, in-memory collection similar to Django's RawQuerySet but with convenience methods like count(), first(), last(), values(), and values_list(). This is especially useful when you rely on database defaults, triggers, or F() expressions to compute field values and need to know what was actually stored without issuing a separate SELECT.

Use it for

  • Retrieve auto-generated or trigger-computed values after bulk inserts without a follow-up query.
  • Update records with F() expressions and immediately see the evaluated result without reloading the instance.
  • Delete rows and capture their final state (e.g., for audit logging) in a single round-trip.
  • Bulk operations that depend on database defaults or computed columns to populate fields.
  • Workflows where you need to confirm what the database actually stored after a DML operation.

Worth the install?

AI-flagged interpretation of the facts on this page. Verify before relying on it.

With conditions

Yes, if you use PostgreSQL and Django and frequently need to return modified rows from bulk operations or F() expressions.

The library is stable and has no known vulnerabilities, but its dormant maintenance (last release 2024-01-04, no recent commits) means it may not support the latest Django versions—verify compatibility with your Django version before adopting. Low install friction and permissive licensing make it a low-risk experiment.

Install

django-pg-returning on PyPI

Before you install

Low friction: pure Python wheel with only django and typing as runtime dependencies. Maintenance is dormant—last release 2024-01-04, no commits since 2024-09-19—so expect no active support or updates for new Django versions.

Requires PostgreSQL 9.4+, psycopg2 or psycopg2-binary (not installed by this package), and Django 1.8+. Some features require Django 1.10+.

License in practice

BSD 3-clause permissive license; you may use, modify, and distribute freely with attribution and no warranty.

Quickstart

pip install django-pg-returning

from django_pg_returning import UpdateReturningModel
from django.db import models

class MyModel(UpdateReturningModel):
    field = models.IntegerField()

result = MyModel.objects.all().update_returning(field=1)
print(result.count())

Verify before relying

  • Whether the library works with current Django versions (4.x, 5.x) given dormant maintenance status.
  • Compatibility with modern psycopg versions (3.x) and whether psycopg2 is still the expected adapter.
  • Performance characteristics when returning large result sets or with complex F() expressions.

Package facts

Licensepermissive license permissive
Python supportNot specified
Install frictionLow. Pure-Python wheel
Runtime dependencies
2 packages
djangotyping
MaintenanceDormant 953 days since the last release
Last repo commit
First released
Downloads178,490 / month, #10,192 on PyPI 30-day window, as of 2026-08-14
Known vulnerabilitiesNone known OSV.dev, checked 2026-08-14

Evidence: django_pg_returning-2.0.2-py2.py3-none-any.whl

Tags

Capabilities
django postgresql returning clausedjango bulk operations with resultsdjango update delete returning rowspostgresql dml returning django ormdjango database triggers resultsdjango f expressions evaluated values
Topics
django-ormpostgresql-specific

Let your AI agent find packages like this

Example. Real query, live index.

You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.

wish › “django postgresql returning clause”

  • django-pg-returningExtends Django's ORM to capture and return rows modified by…
  • buildpgbuildpg constructs PostgreSQL prepared statements with named…
  • django-cteAdds Common Table Expressions (CTE) support to Django's ORM, enabling…

Give your agent the search over MCP, or paste the wish link into any chat.

More Database packages

psycopg2-binary Worth it
PyPI · Software Development · released Apr 2026

psycopg2-binary is a PostgreSQL database adapter for Python that implements the DB API 2.0 specification, enabling Python applications to connect to and query PostgreSQL databases with thread-safe concurrent operations.

copyleftcompiled wheel · 3.9+
271.6Mdownloads / mo
redis Worth it
PyPI · Database · released Jul 2026

Python client library for connecting to and executing commands against Redis key-value stores, supporting both synchronous and asynchronous operations.

Install it if your application needs to interact with Redis; the only prerequisite is a running Redis server instance.

MITpure Python · 3.10+
268.3Mdownloads / mo
ydb Worth it
PyPI · Database · released Jul 2026

YDB Python SDK is the official client library for connecting to and querying YDB databases from Python applications.

Install it if you need to connect Python applications to YDB databases.

permissive licensepure Python · 3.10+
210.0Mdownloads / mo
snowflake-connector-python Worth it
PyPI · Software Development · released Aug 2026

Connects Python applications to Snowflake data warehouses using the DB API 2.0 specification, enabling SQL queries, data transfers, and warehouse operations.

Apache-2.0compiled wheel · 3.10+
193.6Mdownloads / mo
sqlparse Worth it
PyPI · Software Development · released Aug 2026

sqlparse tokenizes SQL text into a tree of statements, clauses, and expressions, and provides functions to split scripts, format queries, and inspect parsed tokens without validating dialect or syntax.

Install it if you need to manipulate, format, or analyze SQL text programmatically.

BSD-3-Clausepure Python · 3.10+
148.9Mdownloads / mo
dbt-adapters With conditions
PyPI · Database · released Jul 2026

Provides base adapter protocols and shared functionality that database adapters use to integrate with dbt-core, handling connections, dialect translation, relation caching, and core interface management.

Apache-2.0pure Python · 3.10.0+
121.3Mdownloads / mo

See also django-pg-bulk-update · django-sql-utils · djangoql · django-bulk-update · django-postgres-copy · drf-extra-fields · django-soft-delete · modelsearch · django-chunkator · django-mock-queries