Django Crie nome de usuário e senha do CSV
import csv, sys, os, django
project_dir = "/parcare/src/"
sys.path.append(project_dir)
os.environ['DJANGO_SETTINGS_MODULE'] = 'adp_parking.settings'
# os.environ.setdefault("DJANGO_SETTINGS_MODULE", __file__)
import django
django.setup()
from django.contrib.auth import authenticate
from django.contrib import admin
from django.contrib.auth.models import User
from django.contrib.auth import get_user_model
from django.conf import settings
User = get_user_model()
file = 'import.csv'
data = csv.reader(open(file), delimiter=",")
for row in data:
if row[0] != "Number":
# Post.id = row[0]
Post=User()
Post.password = row[1]
Post.last_login = "2018-09-27 05:51:42.521991"
Post.is_superuser = "0"
Post.username = row[2]
Post.first_name = row[3]
Post.email = row[4]
Post.is_staff = "1"
Post.is_active = "1"
Post.date_joined = "2018-09-27 05:14:50"
Post.last_name=row[5]
Post.save()
Relieved Rat