saving works now
This commit is contained in:
0
backend/core/management/commands/__init__.py
Normal file
0
backend/core/management/commands/__init__.py
Normal file
33
backend/core/management/commands/create_data.py
Normal file
33
backend/core/management/commands/create_data.py
Normal file
@@ -0,0 +1,33 @@
|
||||
from django.core.management.base import BaseCommand
|
||||
from backend.crm.models import Person
|
||||
from backend.utils import utils as u
|
||||
from backend.utils.progress_bar import progressbar
|
||||
|
||||
|
||||
def get_person():
|
||||
first_name = u.gen_first_name()
|
||||
last_name = u.gen_last_name()
|
||||
email = u.gen_email(first_name, last_name)
|
||||
d = dict(
|
||||
first_name=first_name,
|
||||
last_name=last_name,
|
||||
email=email,
|
||||
)
|
||||
return d
|
||||
|
||||
|
||||
def create_persons():
|
||||
aux = []
|
||||
for _ in progressbar(range(50), 'Persons'):
|
||||
data = get_person()
|
||||
obj = Person(**data)
|
||||
aux.append(obj)
|
||||
Person.objects.bulk_create(aux)
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = 'Create data.'
|
||||
|
||||
def handle(self, *args, **options):
|
||||
self.stdout.write('Create data.')
|
||||
create_persons()
|
||||
18
backend/core/management/commands/hello.py
Normal file
18
backend/core/management/commands/hello.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = 'Print hello world.'
|
||||
|
||||
def add_arguments(self, parser):
|
||||
# Argumento nomeado
|
||||
parser.add_argument(
|
||||
'--awards', '-a',
|
||||
action='store_true',
|
||||
help='Help of awards options.'
|
||||
)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
self.stdout.write('Hello world.')
|
||||
if options['awards']:
|
||||
self.stdout.write('Awards')
|
||||
Reference in New Issue
Block a user