Skip to main content

Recent objects fetching utilities

Usage:

from testapp.models import Article, Comment, Payment

from recent_objects.recent_objects import RecentObjects

ro = RecentObjects(
    [
        {
            "queryset": Article.objects.all(),
            "date_field": "created_at",
        },
        {
            "queryset": Comment.objects.all(),
            "date_field": "created_at",
        },
        {
            "queryset": Payment.objects.all(),
            "date_field": "created_at",
        },
    ]
)

recent_10_objects = ro.page(paginate_by=10, page=1)

recent_10_objects will now be a list of up to 10 dictionaries of the form:

[
  {
      "type": "testapp.article",
      "date": datetime(...),
      "pk": 24,
      "object": Article(),
  },
  {
      "type": "testapp.comment",
      "date": datetime(...),
      "pk": 42,
      "object": Comment(),
  },
  ...
]

You can optionally specify the type yourself in the recent objects spec above. This may be useful when you want more control over the value or if you’re assembling several querysets using the same underlying model.

Metadata

Release files for django_recent_objects 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django_recent_objects 0.1.0
File Size Uploaded
django_recent_objects-0.1.0.tar.gz 4.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django_recent_objects 0.1.0
File Interpreter ABI Platform
django_recent_objects-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 8.4 kB

Release files / django_recent_objects-0.1.0.tar.gz

Download URL django_recent_objects-0.1.0.tar.gz
Size 4.1 kB
Tags Source
SHA-256 checksum
How to use checksums
825d2a6279361ce1c924dc8c338021bafd9e28215e03be9315b0b0a2bbc3aa3a
BLAKE2b-256 checksum
How to use checksums
8dc02fddbc9568fd48a41b0f4ecd03ca6f6a5d32f8d9c334fa934fccc23de6b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.12

Release files / django_recent_objects-0.1.0-py3-none-any.whl

Download URL django_recent_objects-0.1.0-py3-none-any.whl
Size 4.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7feef7b4a733ce7d6e246fc99c53e4aa4b1d2ed81c884af697cc6baebffc37ab
BLAKE2b-256 checksum
How to use checksums
d6c59b6189746da61702091d91ccd7ff9a311d9df6376cdf5deed64b90e05d5b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.12

Release history Release notifications | RSS feed

0.1.1

2 release files

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page