+ create_test_data command
This commit is contained in:
parent
e7284e7725
commit
332ffa3a5f
36
store/management/commands/create_test_data.py
Normal file
36
store/management/commands/create_test_data.py
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
from django.contrib.auth.hashers import make_password
|
||||
from django.core.management import BaseCommand
|
||||
from tqdm import tqdm
|
||||
|
||||
from store.models import User
|
||||
|
||||
users = [
|
||||
{
|
||||
"email": "poizonstore@mail.ru",
|
||||
"password": "219404Poizon",
|
||||
"job_title": User.ADMIN
|
||||
},
|
||||
{
|
||||
"email": "poizonmanager1@mail.ru",
|
||||
"password": "poizonm1",
|
||||
"job_title": User.PRODUCT_MANAGER
|
||||
},
|
||||
{
|
||||
"email": "poizonorder1@mail.ru",
|
||||
"password": "2193071Po1",
|
||||
"job_title": User.ORDER_MANAGER
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = ''' Create test data '''
|
||||
|
||||
def create_test_users(self):
|
||||
for user_data in tqdm(users, desc="Creating users"):
|
||||
user_data['password'] = make_password(user_data['password'])
|
||||
User.objects.get_or_create(email=user_data['email'], defaults=user_data)
|
||||
|
||||
def handle(self, *args, **kwargs):
|
||||
self.create_test_users()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user