Skip to content

Instantly share code, notes, and snippets.

"""
A command tool that generates fixture data (json)
based from existing Models. This can be helpful when
doing testing.
"""
from django.core.management.base import BaseCommand
from django.db import models
from django.db.utils import DatabaseError
@markmeriales
markmeriales / get_max_combination
Created November 15, 2012 02:55
Returns the max combination by character length and base
def get_max_combination(length, base=16):
current = base**(length-1)
next = base**(length)
return next-current
@markmeriales
markmeriales / gist:4058523
Created November 12, 2012 10:23
get_random_hex_by_length
import random
def get_random_hex_by_length(length=4):
"""Returns a random hex code according to length"""
return hex(random.randint((16**((length)-1)),(16**length)))[2:]