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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 825d2a6279361ce1c924dc8c338021bafd9e28215e03be9315b0b0a2bbc3aa3a |
|
MD5 | 9a3ede9838e8220408dcf51663446084 |
|
BLAKE2b-256 | 8dc02fddbc9568fd48a41b0f4ecd03ca6f6a5d32f8d9c334fa934fccc23de6b9 |
File details
Details for the file django_recent_objects-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: django_recent_objects-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7feef7b4a733ce7d6e246fc99c53e4aa4b1d2ed81c884af697cc6baebffc37ab |
|
MD5 | 417b9df1268e0ee3101eb188b519dcb5 |
|
BLAKE2b-256 | d6c59b6189746da61702091d91ccd7ff9a311d9df6376cdf5deed64b90e05d5b |