Skip to content

How to Delete Your User

W. Bomar edited this page Nov 16, 2021 · 4 revisions

Some tasks require a developer to delete their user.

Use Cases

  • Test Onboarding as a user.

Steps

  1. (Optional) Completely shut down all of your containers and restart them.

  2. Login to docker shell:

    docker exec -it core_portal_django /bin/bash
    
  3. Enter python shell:

    python manage.py shell
    
  4. Find & Delete your user:

    from django.contrib.auth import get_user_model
    from portal.apps.onboarding.models import SetupEvent
    # Get your user model (change "my_username" to your username)
    my_user = get_user_model().objects.get(username="my_username")
    # Inspect your user setup events, if things go wrong and we need additional debugging data
    events = SetupEvent.objects.all().filter(user=my_user)
    print(events)
    # Delete your local user to reset your onboarding state
    my_user.delete()
    

Notes

If you are superuser, you can delete a user from the web interface. However, to become superuser you had to get into the shell anyway to perform steps from How to Set Your User as Staff or Superuser.

Reference

Clone this wiki locally