Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

django create username and password from 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()
Comment

PREVIOUS NEXT
Code Example
Python :: python how to hash string into pbkdf2 
Python :: Ipython.display latex in the IDE like spyder 
Python :: pylesson 
Python :: python to java converter 
Python :: features and image recongnition 
Python :: numpy rolling 2d 
Python :: Flask-WTF select field from database 
Python :: when was python 3.7 released 
Python :: flask admin forgeign keys show literal 
Python :: load data batchwise keras 
Python :: how to find pandoc template folder 
Python :: select values for row matching condition 
Python :: Filter Top 5 Python 
Python :: how to add base map in pyqgis 
Python :: currelation matrix python 
Python :: condtion for equal time in selenium python 
Python :: find and flag duplicates pandas 
Python :: selenium python login instagram 
Python :: ssl expired python 
Python :: how to write a table from 1 to 10 with for loop in fython in 3 lines 
Python :: python format method align center 
Python :: printing multiple input in python 
Python :: python loading image file requires absolute path 
Python :: rendere eseguibile python 
Python :: hack instagram account with python 
Python :: u00a0 
Python :: unique mark boolean django model field 
Python :: get ascii value of char python online 
Python :: python global variable that can be iterated 
Python :: plot every nth label in barplot 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =