This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_max_combination(length, base=16): | |
current = base**(length-1) | |
next = base**(length) | |
return next-current |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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:] |