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
Close
Hashes for django-random-queryset-0.2.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf7c28877acb373c2e37279eb2a850261ca7dc37ba1dbb2e32650509512946e6 |
|
MD5 | f7fbf124fe020b92e44c6c1c7eff9ce6 |
|
BLAKE2b-256 | 4775114ce2951f731a887bda5a0e125b7b100481d86944fd6eb1ee5d764241d5 |