Skip to main content

Pull random records using Django ORM.

Project description

Pull random records using Django ORM.

Requirements

  • Python 3.10+

  • Django 4.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 get 5 random records
queryset.random(len(queryset)) # to get all random records
queryset.random().values()  # to have access to other queryset methods

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_random_queryset-0.3.1.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

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

django_random_queryset-0.3.1-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file django_random_queryset-0.3.1.tar.gz.

File metadata

  • Download URL: django_random_queryset-0.3.1.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for django_random_queryset-0.3.1.tar.gz
Algorithm Hash digest
SHA256 278123c82c77ade1f16d5620ef26f1a1efda18b8c60cd70296d9025bbe357dfe
MD5 33cda77e428ac3550bfd5f2b5e0e5ef1
BLAKE2b-256 154137c8713b41407089d4f2039b862101fce7f153315b94960aaaf0d9f9c8f5

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_random_queryset-0.3.1.tar.gz:

Publisher: publish.yml on rremizov/django-random-queryset

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_random_queryset-0.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for django_random_queryset-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 06b3a24164ccf8f17c1aab4c7c88a4e024880bda0e3028a69aece283e6dcca17
MD5 db12d52665c259f899a7495ca9bce0be
BLAKE2b-256 531d9a14ff25fc63dd5145367a1ef7b2927c47b256e66d5808f497619d245f93

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_random_queryset-0.3.1-py3-none-any.whl:

Publisher: publish.yml on rremizov/django-random-queryset

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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