Pull random records using Django ORM.
Project description
Pull random records using Django ORM.
Requirements
Python 3.8+
Django 3.2+
Installation
$ pip install django-random-queryset
Setup
Add RandomManager to desired model:
from django.db import models
from django_random_queryset import RandomManager
class Model(models.Model):
objects = RandomManager()
# ...
No database migrations are needed.
How to use it:
queryset = Model.objects.filter(field=value)
queryset.random() # to get one random record
queryset.random(5) # to pass limited random records
queryset.random(len(queryset)) # to get all random records
queryset.random().values() # to have access to other queryset methods
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
File details
Details for the file django-random-queryset-0.2.0.tar.gz
.
File metadata
- Download URL: django-random-queryset-0.2.0.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
bf7c28877acb373c2e37279eb2a850261ca7dc37ba1dbb2e32650509512946e6
|
|
MD5 |
f7fbf124fe020b92e44c6c1c7eff9ce6
|
|
BLAKE2b-256 |
4775114ce2951f731a887bda5a0e125b7b100481d86944fd6eb1ee5d764241d5
|