# Generated by Django 3.0.8 on 2020-07-18 15:47

from django.contrib.auth import get_user_model
from django.db import migrations
import requests


def create_users(apps, schema_editor):
    User = get_user_model()

    url = "https://jsonplaceholder.typicode.com/users"
    response = requests.get(url)
    api_users = response.json()

    for user in api_users:
        User.objects.create_user(
            name=user.get("name"),
            email=user.get("email"),
            username=user.get("username"),
            phone=user.get("phone"),
            website=user.get("website"),
            password="12345"
        )


class Migration(migrations.Migration):

    dependencies = [
        ('users', '0001_initial'),
    ]

    operations = [
        migrations.RunPython(create_users),
    ]
