Skip to main content

Recent objects fetching utilities

Project description

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.

Project details


Download files

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

Source Distribution

django_recent_objects-0.1.0.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

django_recent_objects-0.1.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file django_recent_objects-0.1.0.tar.gz.

File metadata

  • Download URL: django_recent_objects-0.1.0.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.12

File hashes

Hashes for django_recent_objects-0.1.0.tar.gz
Algorithm Hash digest
SHA256 825d2a6279361ce1c924dc8c338021bafd9e28215e03be9315b0b0a2bbc3aa3a
MD5 9a3ede9838e8220408dcf51663446084
BLAKE2b-256 8dc02fddbc9568fd48a41b0f4ecd03ca6f6a5d32f8d9c334fa934fccc23de6b9

See more details on using hashes here.

File details

Details for the file django_recent_objects-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_recent_objects-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7feef7b4a733ce7d6e246fc99c53e4aa4b1d2ed81c884af697cc6baebffc37ab
MD5 417b9df1268e0ee3101eb188b519dcb5
BLAKE2b-256 d6c59b6189746da61702091d91ccd7ff9a311d9df6376cdf5deed64b90e05d5b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page