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",
            # "type": "testapp.article",
        },
        {
            "queryset": Comment.objects.all(),
            "date_field": "created_at",
            # "type": "testapp.comment",
        },
        {
            "queryset": Payment.objects.all(),
            "date_field": "created_at",
            # "type": "testapp.payment",
        },
    ]
)

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.1.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_recent_objects-0.1.1-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_recent_objects-0.1.1.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for django_recent_objects-0.1.1.tar.gz
Algorithm Hash digest
SHA256 79709d5ddb9f799cbcf2348a0ca915a15b9384ff5af42216d28204ec520066c8
MD5 5956438edd0f776889bb92fd8a85e17b
BLAKE2b-256 3e87f097c576ec0f57bdb1175d799d7d67a25a4aa5dece1758e17c413ebb65e9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_recent_objects-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 76f232ff8bb113c24096f0d18a9b592e4df8866c2016f2a6e4c69f2c5e1014d6
MD5 fce97d0f07d18c8af43cc3041ea0503e
BLAKE2b-256 70bb46e84613b94bf8b3b8567a7634567ad4a907f6797278eaf440c99db7db91

See more details on using hashes here.

Supported by

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