random_instances

Software Screenshot:
random_instances
Software Details:
Version: 0.0.3
Upload Date: 11 May 15
Developer: Red Interactive
Distribution Type: Freeware
Downloads: 0

Rating: nan/5 (Total Votes: 0)

random_instances is an utility to retrieve or generate random instances of Django models.

This module exports a get_or_create_random function that improves Django's get_or_create (http://djangoproject.com/documentation/models/get_or_create/) on two aspects:

* invoking get_or_create_random with parameters that match MULTIPLE instances does not raise an error, but rather returns one of those instances at random

* invoking get_or_create_random with parameters that do not match ANY instance returns a NEW instance of that model (the same occurs with get_or_create). The improvement is that get_or_create_random can be invoked without passing a value for all the 'required' fields of the model. If these fields are not passed, they are automatically filled with random values (e.g.: CharFields are filled with random strings, ImageFields with random images).

The goal is to make prototyping faster, as model instances can be obtained and created by specifying just the minimum set of desired fields. This is useful when writing tests and can avoid having to write complex fixtures.

Requirements:

  • Python

Similar Software

Tarn
Tarn

14 Apr 15

vncdotool
vncdotool

12 May 15

PyHamcrest
PyHamcrest

11 May 15

lava-ci
lava-ci

11 May 15

Comments to random_instances

Comments not found
Add Comment
Turn on images!