from django.contrib.auth.models import Group, Permission from django.contrib.contenttypes.models import ContentType from django.core.management import BaseCommand from django.utils import timezone import pydash as _; _.map = _.map_; _.filter = _.filter_ import random from archilance import util from projects.models import Project, CURRENCIES, TERMS class Command(BaseCommand): def handle(self, *args, **options): print('---------------------------------------') print('Generating projects...') print('---------------------------------------') # Fields: # # [('files', True), # ('answers', True), # ('order', True), # ('candidates', True), # ('reviews', True), # ('customer', True), # ('realty', True), # ('specialization', True), # # ('id', False), # ('budget', False), # ('budget_by_agreement', False), # ('created', False), # ('cro', False), # ('currency', False), # ('name', False), # ('price_and_term_required', False), # ('deal_type', False), # ('term', False), # ('term_type', False), # ('text', False), # ('work_type', False), # ('state', False)] def create_project(i): # project = Project() # pr.specialization = # pr. return Project.objects.create( budget=util.random_amount(), budget_by_agreement=_.sample((True, False)), created=util.random_date(), cro=_.sample((True, False)), currency=_.sample(CURRENCIES)[0], name='Project %s' % i, price_and_term_required=_.sample((True, False)), deal_type=_.sample(Project.DEAL_TYPES)[0], term=_.random(0, 20), term_type=_.sample(TERMS)[0], text='Project %s text' % i, work_type=_.sample(Project.WORK_TYPES)[0], state='active', ) projects = _.times(create_project, 1000)