Uploading users in bulk in Django

If you have access to the hosted server:

  • You can get into the kpi container doing:
    docker exec -it <kpi> bash
  • Then enter the Django shell:
    ./manage.py shell_plus
  • Then from inside the ipython shell, you can create a user doing the following:
    User.objects.create(username='<some new user>')
  • Or if you are creating a whole bunch of users:
for user in users:
    User.objects.create(username=user)

(Additionally you can assign permissions to those users as you create them through the shell — perhaps listing usernames and permissions in your spreadsheet, importing that and iterating through as you create and assign, etc. I can send through some sample code if that will be useful)

3 Likes