You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
Roman Remizov e4f0d3cd90
Merge pull request #227 from rremizov/dependabot/pip/flake8-5.0.1
2 weeks ago
.github Upgrade to GitHub-native Dependabot 1 year ago
django_random_queryset Wrap ".random()" into db transaction 2 years ago
tests Dump Travis CI 1 year ago
.gitignore Minor .gitignore change 2 years ago
.isort.cfg Use "black" 3 years ago
LICENSE Update LICENSE 2 years ago
MANIFEST.in Version 0.1.0 4 years ago
Makefile Use "black" 3 years ago
README.rst Update Travis CI badge 2 years ago
docker-compose.yml Use pytest 4 years ago
manage.py Use pytest 4 years ago
requirements-test-python2 Dependabot, stay away from Python 2! 2 years ago
requirements-test.txt Bump flake8 from 4.0.1 to 5.0.1 2 weeks ago
setup.py Update LICENSE 2 years ago
tox.ini Dump Travis CI 1 year ago

README.rst

django-random-queryset Build status

Pull random records using Django ORM.

Requirements

  • Python 2.7, 3.6, 3.7
  • Django 1.11, 2.0, 2.1, 2.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